我希望所有.box p顏色都是粉紅色,但似乎所有在#container中的.box p都有紅色。我希望級聯會改變顏色,但我認爲我犯了一個錯誤。Cascading Parent-Child
你能告訴我我錯了嗎?
感謝
/_ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ ____
<html>
<head>
<title> Buvbvn</title>
<style type="text/css">
p {color: #F00;}
/* container holds all visible page elements */
#container{
padding:20px;
border:20px solid #000;
background: #CCC;
}
.box{
margin: 10px;
padding:20px;
border: 1px solid #000;
}
/* Make text red only for paragraphs within the container */
#container p {
color: #F00;
}
/* Make text pink only for paragraphs within the box class */
.box p {
color: #FF00FF;
}
</style>
</head>
<body>
<div id ="container">
<p>This is our content area.</p>
<div class = "box">
<p >I'm in a box!</p>
</div>
<div class = "box">
<p >I'm also in a box!</p>
</div>
</div>
<div class = "box">
<p >I'm also in a box!</p>
</div>
</body>
做什麼? – Maverick 2011-04-23 16:12:12