使用伪元素为什么不添加position属性就不显示

来源:3-3 header头部导航条制作

抓住这只猪

2019-11-01 10:15:36

.header__nav-item_status_active::after{
    content: '';
    width: 100%;/*继承父元素*/
    height: 2px;
    background-color: #f01400;
    position: absolute;
    left: 0;
    bottom: 0;
}

写回答

1回答

好帮手慕码

2019-11-01

同学你好!

伪元素默认是行内元素, 需要修改display属性值为block;或者是设置定位(定位之后display属性值为block哦),让其显示为块级元素才可以显示出来哦!

如果帮到了你,欢迎采纳,祝学习愉快~

0

0 学习 · 40143 问题

查看课程