在SASS中是否可以继承另一个文件中的类? [英] Is it possible in SASS to inherit from a class in another file?

查看:132
本文介绍了在SASS中是否可以继承另一个文件中的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,如果我使用,说, 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆