how to alias class name in css or sass

后端 未结 6 1997
青春惊慌失措
青春惊慌失措 2020-12-09 07:15

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

6条回答
  •  [愿得一人]
    2020-12-09 08:02

    You can use SASS mixin @content to create an alias for a selector or combination of them like this:

    @mixin icon {
       .icon-globe,
       .globe {
          @content;
       }
    }
    
    @include icon {
       font-size: 16px;
    }
    

    SASS will generate this for you:

    .icon-globe,
    .globe {
       font-size: 16px;
    }
    

    Read more about SASS mixin content block;

提交回复
热议问题