在SASS中是否可以继承另一个文件中的类? [英] Is it possible in SASS to inherit from a class in another file?
问题描述
例如,如果我使用,说, Twitter Bootstrap ,我可以在我自己的SASS样式表中定义继承自Bootstrap的CSS类的类吗?或者SASS中的继承只在单个文件的范围内工作?
如果您希望所有< button>
元素继承 .btn
来自 Twitter Bootstrap的默认按钮的类
在 styles.scss
文件中,您必须首先导入 _bootstrap.scss
:
@import_bootstrap.scss;
然后在导入下面:
按钮{@extend .btn; }
The question pretty much says it all.
For instance, if I were using, say, Twitter Bootstrap, could I define classes in my own SASS stylesheet that inherit from Bootstrap's CSS classes? Or does inheritance in SASS only work within the scope of a single file?
YES! its possible.
If you want all <button>
elements to inherit the .btn
class from Twitter Bootstrap's Default buttons
In your styles.scss
file you would have to first import _bootstrap.scss
:
@import "_bootstrap.scss";
Then below the import:
button { @extend .btn; }
这篇关于在SASS中是否可以继承另一个文件中的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!