CSS的伪元素就是通过CSS来给标签添加内容,默认标签的内容是通过HTML来添加的
通常给伪元素的父级元素添加一个iconfont或者其他样式:
<div class="wrapper">PANEL DEMO</div>复制代码
.wrapper {
width: 140px;
text-align: center;
margin: 30px;
position: relative;
}
.wrapper::after {
content: '';
position: absolute;
bottom: -4px;
left: -5px;
height: 2px;
width: 150px;
background-color: #000;
}复制代码
伪元素根据父元素定位即可,效果: