【发布时间】:2015-06-07 05:25:31
【问题描述】:
我想让作为 div foo 的直接子级的段落具有蓝色文本,而所有其他段落都具有蓝色文本,但我编写的 css 将该样式应用于嵌套
标签也包含在 div 中。
CSS:
p {
color:red;
}
#foo > p{
color: blue;
}
HTML
<html>
<head>
<link type="test/css" rel="stylesheet" href="test.css"/>
</head>
<body>
<div id="foo">
<p>
This is the first line.<br/>
This is the second line
<p>Nested Paragraph</p>
</p>
</div>
<p>Paragraph in new div</p>
</body>
</html>
输出(铬)
这是第一行。 (蓝色的) 这是第二行(蓝色)
嵌套段落(蓝色)
新 div 中的段落(红色)
【问题讨论】:
-
恐怕你必须编辑你的问题以使其更清晰......更清晰以使有点意义。
标签: css