2012-09-12 28 views
1

如果CSS樣式中缺少樣式,這是什麼意思?它也對元素沒有影響。CSS規則中的樣式在Firebug中缺失

在螢火蟲中有一個空的CSS規則。我知道,如果某種風格被覆蓋,風格是交叉的,但我不確定這是什麼意思,如果風格缺失的CSS規則內。我創建了規則來影響下面元素的填充頂部。

<div id="leadspace-head" class="alternate"> 
    <div id="leadspace-body"> 
    <ul id="navigation-trail"> 
     <li>test</li> 
    </ul> 
    <h1 class="small">Title for this page</h1> 
    </div> 
</div> 

這裏是場景。對於上面的html代碼,我有3條css規則。第一個是在body內部,另外兩個規則可以在css文件中找到。第二條規則會覆蓋第三條規則。我添加了第1條規則來覆蓋第2條規則,但它沒有效果,並在螢火蟲中顯示空規則。在mystyle.css身體

.landing-page #leadspace-head.alternate #navigation-trail + h1 { 
    padding-top: 9px !important; 
} 

CSS內

CSS

.landing-page #leadspace-head.alternate #navigation-trail + h1 { 
    padding-bottom: 10px; 
    padding-top: 9px; 
} 

.landing-page #leadspace-head #navigation-trail + h1 { 
    padding-top: 5px; 
} 
+0

你是什麼意思的「身體內的CSS風格」?它是內聯樣式嗎? – BoltClock

+0

樣式標籤在body標籤內無效:http://stackoverflow.com/questions/4803518/why-cant-style-tags-within-the-html-body-tag-validate-on-w3c – tuff

+0

@tuff是你確定? http://css-tricks.com/saving-the-day-with-scoped-css/或http://html5doctor.com/the-scoped-attribute/ ...雖然目前沒有瀏覽器支持它,但我瞭解。 – cimmanon

回答

1

你的風格似乎是壓倒一切對方很多。你可能想要研究如何更好地使用CSS中的繼承規則。

這且不說,嘗試重新寫你的規則是:

#navigation-trail h1.small { padding-top: 9px; } 

這將特別針對你的#導航路徑列表元素落在那些H1元素。