2010-10-06 209 views
1

我有一個類:簡單的嵌套問題

.header { background-color: #233574} 

我想只有我的樣式類中的H1,H2,H3,H4,H5,H6。我認爲這是這樣寫的:

.header{} 
.header h1 h2 h3 h4 h5 h6 { color: #FFFFFF} //Style these elements within the .header class 

<div class="header"> 
<h1>Header</h1> 
</div> 

我做錯了什麼? h元素仍然沒有挑選出風格?

回答

6

你在做什麼只會風格h6標籤在h5標籤內,並且最終嵌套在.header之內。如果要單獨設計每個標題,則需要執行以下操作:

.header h1, .header h2, .header h3, .header h4, .header h5, .header h6 
    { color: #FFFFFF} //Style these elements within the .header class