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>
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