Can I create an alias to a css class?
I am using this font-awesome and I am trying to create an alias name for some of the icon classes. So that .icon-globe will also called .globe.
How can I accomplish such thing?
Can I create an alias to a css class?
I am using this font-awesome and I am trying to create an alias name for some of the icon classes. So that .icon-globe will also called .globe.
How can I accomplish such thing?
You can apply the same styles to several classes using plain css comma separated selectors:
Will apply the same styles to
<i class="icon-globe">
and<i class="globe">
.You may be interested in CSS Crush which allows you to create aliases http://the-echoplex.net/csscrush/#core--selector-aliases
Usage
Outputs
Easiest way I can think of is to use javascript/jquery.
jQuery:
There's no such thing as aliasing. Sass does have the
@extend
directive, but the solution isn't entirely obvious until you look into the source.Source: https://github.com/FortAwesome/Font-Awesome/blob/master/sass/font-awesome.scss
Even if you made
.globe
extend.icon-globe
, you'll be missing out on most of what makes the FontAwesome styles because of how they built the selector. You have to extend the other selector as well.Generates:
Note that the
icon-
prefix was deliberate. You get smaller CSS files this way, rather than attaching all of those styles to all ~200 classes that come with FontAwesome. You can do it, but I don't think the result is very good.You can easily do this with
SASS
by extending theicon-globe
classThe output CSS will be as,
Considering the new class names of Font-Awesome, you will be need to using the
.fa-globe
with multiple class extendingThe output CSS will be as,