I want to have a CSS selector for a header with custom font, color and a bullet to the left. So I want my header to use my custom font, and it's :before
pseudo-element to use font-awesome. So I would like my :before
to have the .fa
class, while the whole element doesn't have this class.
I have this html: <h1 class="bulleted-header">Hello</h1>
And I would like to write something like this in LESS:
.bulleted-header {
color: #61cbe6;
font: 16px 'ds_goose', sans-serif;
&:before {
content: @fa-var-bullseye; // font-awesome's bullet icon
.fa; // calling font-awesome's class. DOESN'T COMPILE
}
}
The problem is that .fa
class is declared like this in font-awesome LESS sources: .@{fa-css-prefix} { ... }
, so the code above doesn't compile. I tried to reuse the .fa
code like this:
&:before {
content: @fa-var-bullseye; // font-awesome's bullet icon
.@{fa-css-prefix}; // DOESN'T COMPILE
}
and like this:
&:before:extend(.@{fa-css-prefix}) { // compiles but no effect
content: @fa-var-bullseye; // font-awesome's bullet icon
}
I know I can just change my html like this <h1 class="bulleted-header"><span class = "fa fa-bullseye"></span>Hello</h1>
and not to use :before
at all, but it's more logical to keep all this bullets thing in CSS.
I ended up just copy-pasting the content of .fa
into my :before
, but there is something wrong in this approach because now I have to maintain this code myself in case FA guys change something. Are there any more elegant solutions?