1.什么是伪元素选择器?
作用:
- 给指定标签的内容前面添加一个子元素或者给指定标签的内容后面添加一个子元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>伪元素选择器</title>
<style>
.box{
width: 200px;
height: 200px;
background: red;
}
.box::before{
content: "“我是”";
width: 50px;
height: 50px;
background: pink;
display: block;
}
.box::after{
content: "“yo”";
width: 50px;
height: 50px;
background: pink;
display: block;
}
</style>
</head>
<body>
<div class="box">
leo
</div>
</body>
</html>
网友评论