:first-child伪类在CSS中的用法
使用:first-child伪类为元素添加特殊样式,该元素是某个其他元素的第一个子元素。
示例
您可以尝试运行以下代码来了解:first-child伪类的用法-
<html>
<head>
<style>
div > p:first-child
{
text-indent: 25px;
}
</style>
</head>
<body>
<div>
<p>First paragraph in div. This paragraph will be indented</p>
<p>Second paragraph in div. This paragraph will not be indented</p>
</div>
<p>But it will not match the paragraph in this HTML:</p>
<div>
<h3>Heading</h3>
<p>The first paragraph inside the div. This paragraph will not be effected.</p>
</div>
</body>
</html>热门推荐
10 初八祝福语简短语
11 庆双节祝福语简短
12 夸赞老师祝福语搞笑简短
13 学生祝福语简短古诗大全
14 团队文案祝福语简短励志
15 孩子16岁祝福语简短
16 美丽晚霞祝福语简短句
17 新年祝福语长篇文案简短
18 药店祝福语简短10字