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?
例如,如果我使用Twitter Bootstrap,我可以在我自己的SASS样式表中定义类,从Bootstrap的CSS类继承吗?还是SASS中的继承只在单个文件的范围内工作?
3 个解决方案
#1
121
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
:
在你的风格。您必须首先导入_bootstrap.scss文件:
@import "_bootstrap.scss";
Then below the import:
然后导入以下:
button { @extend .btn; }
#2
7
**I might be mistaken, but if I get what you're trying to do, can't you just use the @extend .classname;
command inside the element that you'd want to extend? Naturally, you should only modify your own code to preserve updatability.
**我可能搞错了,但如果我明白了您的意图,您就不能使用@extend .classname;要扩展的元素中的命令?当然,您应该只修改自己的代码以保持可更新性。
#3
2
To my knowledge, you have to use @import
of the file containing the classes you want to use into your SASS file in order to utilize them in that file. However, I am not a SASS/SCSS expert, so someone may know of another way to remotely use them that I am not aware of.
据我所知,您必须在SASS文件中使用包含要使用的类的文件的@import,以便在该文件中使用它们。然而,我不是SASS/SCSS专家,因此有人可能知道另一种远程使用它们的方法,而我对此并不知情。
#1
121
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
:
在你的风格。您必须首先导入_bootstrap.scss文件:
@import "_bootstrap.scss";
Then below the import:
然后导入以下:
button { @extend .btn; }
#2
7
**I might be mistaken, but if I get what you're trying to do, can't you just use the @extend .classname;
command inside the element that you'd want to extend? Naturally, you should only modify your own code to preserve updatability.
**我可能搞错了,但如果我明白了您的意图,您就不能使用@extend .classname;要扩展的元素中的命令?当然,您应该只修改自己的代码以保持可更新性。
#3
2
To my knowledge, you have to use @import
of the file containing the classes you want to use into your SASS file in order to utilize them in that file. However, I am not a SASS/SCSS expert, so someone may know of another way to remotely use them that I am not aware of.
据我所知,您必须在SASS文件中使用包含要使用的类的文件的@import,以便在该文件中使用它们。然而,我不是SASS/SCSS专家,因此有人可能知道另一种远程使用它们的方法,而我对此并不知情。