【发布时间】:2021-07-14 14:38:39
【问题描述】:
背景
我有一个想要导入 Bootstrap CSS 样式的现有网站。样式有冲突,所以我想确定规则的范围。
示例
// node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_modals.scss
.modal {
display: none;
overflow: hidden;
position: fixed;
top: 0;
right: 0;
bottom: 0;
}
// ---
// my-styles.scss
.my-selector {
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/modals";
}
这导致.my-selector .modal,但我想要.my-selector.modal。
我想避免复制粘贴样式规则。如果我能以某种方式使用@extend 做到这一点,那就太好了。
感谢您的任何建议。
【问题讨论】:
-
为什么要导入
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap/modals";而不是 Bootstrap SASS 源? .. 这是一个叫做 boostrap-sass 的特殊项目吗? -
Bootstrap v3 是用 Less 编写的。有一个名为
bootstrap-sass的 Sass 版本。
标签: css twitter-bootstrap sass twitter-bootstrap-3 bootstrap-sass