css3 “::after” pseudo-element not working

我们两清 提交于 2019-12-02 06:40:15

问题


I want to add a triangle after a div tag.Therefore i used css3 after pseudo-element. But it's not working. Following is my css rule.

.header-wrapper .part1 ::after {
    width: 0;
    height: 0;
    border-left: solid 48.35px #f21e1e;
    border-bottom: solid 48.35px transparent;
    border-top: solid 48.35px transparent;
}

Following is my html part

<div class="header-wrapper">
    <div class="part1"></div>
</div>

回答1:


In order for the pseudo element to be generated, you need to specify a content value. The value is otherwise assumed to be the default, none - which is likely why it isn't working in your case. (example)

.header-wrapper .part1::after {
    content: '';
    width: 0;
    height: 0;
    border-left: solid 48.35px #f21e1e;
    border-bottom: solid 48.35px transparent;
    border-top: solid 48.35px transparent;
}

Based on the CSS you posted, you should also remove the space between .part1 ::after.



来源:https://stackoverflow.com/questions/25598530/css3-after-pseudo-element-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!