How to reuse a class in sass without using a mixin

2020-02-24 12:02发布

I want all my anchors in my application look like .btn (Twitter Bootstrap class), is there a way to make this?

I did

a{
  @include btn;
}

but it does not work because btn should be a mixin, and it's a Twitter Bootstrap class.

2条回答
Viruses.
2楼-- · 2020-02-24 12:35

You want to use @extend .btn; - @extend allows you to inherit all the properties of a selector without having to define it as a mixin.

查看更多
\"骚年 ilove
3楼-- · 2020-02-24 12:40

This is exactly what you want => https://github.com/thomas-mcdonald/bootstrap-sass

  1. Install the gem bootstrap-sass
  2. In config.rb => require 'bootstrap-sass'
  3. @import "bootstrap"; at the top of your scss file.

To use write

a {
  @extend .btn;
}
查看更多
登录 后发表回答