How to reuse a class in sass without using a mixin? [duplicate]

三世轮回 提交于 2019-11-29 05:12:12

问题


This question already has an answer here:

  • Including another class in SCSS 5 answers

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.


回答1:


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.




回答2:


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;
}


来源:https://stackoverflow.com/questions/11400219/how-to-reuse-a-class-in-sass-without-using-a-mixin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!