2013-06-26 30 views

回答

3

它是如何 「不正常」?請記住,color:是一個繼承的屬性。如果你想將它排除在外,然後做到這一點:

div div { color: black; } 
.Root > div { color: green; } 
+0

爲什麼顏色被繼承但邊框不是?我的意思是,爲什麼某些屬性會被繼承,而另一些則不是? – Yamcha

+2

@ user1316459:你認爲邊界應該被繼承是合理的嗎? – BoltClock

+0

爲什麼你認爲色彩應該被繼承是有意義的? – Yamcha

0
<div class="Root"> 
    <div>direct child 1</div> <!-- this div is being colored --> 

    <div>  <!-- this div is being colored! still a direct child--> 
     <div>indirect child 1</div> <!-- color is being inherited --> 
     <div>indirect child 2</div> <!-- color is being inherited --> 
    </div> 

    <div>direct child 2</div> <!-- this div is being colored --> 
</div> 

的包裝div仍然是一個直接的孩子。