Reputation: 33
I am trying to put a css triangle before my span and for some reason nothing is showing up at all, any idea what is wrong?
.triangle:before {
width: 0;
height: 0;
border-top: 3px solid transparent;
border-right: 6px solid green;
border-bottom: 3px solid transparent;
right: 100%;
top: 0%;
position: absolute;
clear: both;
}
.triangle {
position: relative;
}
<span class="triangle">Hi</span>
Upvotes: 0
Views: 2737
Reputation: 728
You forgot
content : '';
in your css
.triangle::before{
content:'';
width: 0;
height: 0;
border-top: 3px solid transparent;
border-right: 6px solid green;
border-bottom: 3px solid transparent;
right:100%;
top:0%;
position: absolute;
clear: both;
}
Upvotes: 4
Reputation: 9642
You have forgot to pass content:''
in your css, check updated snippet below:
.triangle::before{
content: '';
width: 0;
height: 0;
border-top: 3px solid transparent;
border-right: 6px solid green;
border-bottom: 3px solid transparent;
right:100%;
top:7px;
position: absolute;
}
.triangle{
position: relative;
display: inline-block;
}
<span class="triangle">HI</span>
Upvotes: 3
Reputation: 58422
Your span needs to use class
not className
and you need to add content:''
to your before css:
.triangle::before{
content:'';
width: 0;
height: 0;
border-top: 3px solid transparent;
border-right: 6px solid green;
border-bottom: 3px solid transparent;
right:100%;
top:0%;
position: absolute;
clear: both;
}
.triangle{
position: relative;
}
<span class="triangle">Hi</span>
Upvotes: 2