SASS - Extend class across multiple files

▼魔方 西西 提交于 2019-12-03 13:16:27

That's what placeholders made for. Instead of this:

.stretch { color: #F00 }
.a { @extend .stretch; }
.b { @extend .stretch; }
.c { @extend .stretch; }

use this:

%stretch { color: #F00 }
.a { @extend %stretch; }
.b { @extend %stretch; }
.c { @extend %stretch; }

It will produce the following css:

.a, .b, .c {
  color: red; 
}

I.e. the stretch class is not included in the final compiled CSS, but you could still use it in SASS.

Use the @import method in Sass. This makes available to another sass file all the mixings, variables and more.

http://sass-lang.com/tutorial.html

in origin.sass

$variable_color = #877889

.one, .another, .two
  @extend .fatherclass

in another.sass

@import origin

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