I have a fieldset
containing a legend
that has a ::before
pseudo-element and I want this pseudo-element to be positioned above the legend
without affecting the legend
's position.
HTML:
<fieldset>
<legend>THE TEXT</legend>
</fieldset>
CSS:
legend {
padding:0 14px;
}
legend::before {
content:'BEFORE ';
color:red;
}
I tried adding legend::before { vertical-align:super }
but it puts the legend
element down like this:
JSFiddle demo superscript (without success)
Any idea's would be welcome to accomplish this.
Use
position: absolute;
on the pseudo element like this:EDIT:
If you would like the text to appear beside the legend then use the
left
attribute.See updated jsFiddle