- 代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.father{
width: 500px;
height: 500px;
background-color: #e0e0e0;
display: flex;
justify-content: center;
align-items: center;
}
.father .selfSon{
display: inline-block;
background-color: skyblue;
width: 200px;
height: 200px;
}
.father::before{
content: "before内容";
width: 200px;
height: 200px;
background-color: pink;
}
.father::after{
content: "after内容";
width: 200px;
height: 200px;
background-color: pink;
}
</style>
</head>
<body>
<div class="father">
<div class="selfSon">父级中自身的内容</div>
</div>
</body>
</html>
- 运行结果
