Here is a demo of the element that I currently have, styled to have an arrow-like ending pointing to the right:
.label {
position: relative;
display: inline-block;
padding: .5rem .75rem;
line-height: 1rem;
color: white;
background-color: darkred;
box-sizing: border-box;
}
.label:after {
content: ' ';
position: absolute;
top: 0;
right: -.5rem;
border-top: 1rem solid transparent;
border-left: .5rem solid darkred;
border-bottom: 1rem solid transparent;
box-sizing: border-box;
}
<span class="label">
BREAKING NEWS
</span>
<br><br>
<span class="label">
BREAKING <br>
NEWS
</span>
But, since border-width
doesn't accept percentages, this means I cannot declare the height of that little arrow appendage to be 50% of the height of the element. Instead, I have to declare the borders of that appendage as a specific height (1rem
in my case). That means that this kind of solution cannot support text spanning through more than 1 line, because the arrow appendage doesn't fit the height of the element anymore.
So, the first usage of it is the look I want, the second one is a showcase of where it goes wrong.
Could the CSS be written to still have that look, but support a variable height?