2015-06-12 78 views
-1

我是新來的CSS,我有這個問題,我的HTML不使用我定義的一些CSS規則。 我有這樣的HTML:HTML不使用CSS規則

<!DOCTYPE html> 

<html ng-app="sample", lang="he"> 
<head> 
    <title>Project</title> 

    <meta charset="utf-8"> 

    <link rel="stylesheet" type="text/css" href="bootstrap.min.css" /> 
    <link rel="stylesheet" type="text/css" href="main.css"> 

    <script type="text/javascript" src="angular.min.js"></script> 
    <script type="text/javascript" src="app.js"></script> 
</head> 

<body> 
    <div ng-controller="AppController as app"> 
     <div class="peoplelist", ng-repeat="person in app.people.data"> 
      <p class="name">{{person.first + ' ' + person.last}}</p> 
      <p class="id">{{person.id}}</p> 
     </div> 
    </div> 
</body> 
</html> 

這個CSS:

p.name { 
    font-family: "David"; 
    font-size: 20px; 
    margin: 0rem; 
    float: right; 
} 

p.id: { 
    font-size: 12px; 
    margin: 0rem; 
    float: right; 
} 

div.peoplelist: { 
    margin: 5rem; 
    float: right; 
} 

當我在我的瀏覽器(Chrome)中打開HTML我可以看到,第一條規則(p.name)使用,但其他2個都沒有,瀏覽器忽略它。當我檢查它時(Ctrl + Shift J),我看到規則與元素沒有關聯。

我似乎無法在網上找到答案。 有人能告訴我代碼有什麼問題嗎?

TNX

+1

不要使用,來分隔屬性。使用空間 – progsource

+0

請使用體面的IDE來防止您未來陷入此類錯誤。 –

回答

2

有沒有:在規則的結尾。第一條規則是正確的。在末尾刪除:

p.id: {} 
----^ 
div.peoplelist: {} 
--------------^ 

除去上面說從規則:。你的最後一張應該是這樣的:

p.id { 
    font-size: 12px; 
    margin: 0rem; 
    float: right; 
} 

div.peoplelist { 
    margin: 5rem; 
    float: right; 
} 

還有一件事。對於HTML屬性,沒有逗號!

<html ng-app="sample", lang="he"> 
<!-------------------^ 

刪除!使用空格:

<html ng-app="sample" lang="he">