: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 怎样给人送祝福语简短
17 送离职同事简短祝福语
18 送师姐的祝福语简短