Vì tôi hiểu các yếu tố ít nhất là cụ thể. (yếu tố vs id). Xin hãy giúp tôi hiểu rõ tính đặc trưng của các bộ chọn.Trình chọn yếu tố cụ thể hơn bộ chọn id như thế nào?
<div id="container">
<div id="firstDiv">FIRST Div inside CONTAINER</div>
<div id="secondDiv">SECOND Div inside CONTAINER</div>
</div>
body{
width: 780px;
margin: 20px auto;
}
#container > div:not(:last-of-type){
margin-bottom: 0px; /*How its more specific than ID selector below? */
}
#container {
border: 15px solid orange;
padding: 10px;
}
#firstDiv{
margin: 50px; /*This is not taking effect*/
border: 5px solid blueviolet;
}
#secondDiv{
border: 5px solid brown;
}
Hãy nhìn vào http://www.w3.org/TR /CSS2/cascade.html#specificity. –