CSS伪类选择器扩展

:first-childp:first-child选择属于父元素的第一个子元素的每个 元素。
:last-child p:last-child 选择属于其父元素最后一个子元素每个 元素。
:before p:before 在每个 元素的内容之前插入内容。
:after p:after 在每个 元素的内容之后插入内容。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>

.c1:after{ #c1下添加内容如下:
display: block; #添加块标签
margin: 50px 0; #前后间距50像素 左右间隔0
content: "DIV"; #添加内容
color: green; #内容颜色
}
</style>
</head>
<body>

<p class="c1">p1</p>
<p>p2</p>

</body>
</html>

 

posted @ 2022-05-22 20:57  呼长喜  阅读(18)  评论(0编辑  收藏  举报