twitter-bootstrap 如何覆盖sass中的引导程序变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46505841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 01:05:11  来源:igfitidea点击:

How to override bootstrap variables in sass?

htmltwitter-bootstrapvariablessassframeworks

提问by SUNGRAIZ FARYAD

I was trying to customize a Bootstrap 4. I want to copy settings from _variable.scss file to _custom.scss to override. But I didn't find _custom.scss file in source code. How do I add this _custom.scss file in my project?

我试图自定义 Bootstrap 4。我想将设置从 _variable.scss 文件复制到 _custom.scss 以进行覆盖。但是我在源代码中没有找到 _custom.scss 文件。如何在我的项目中添加这个 _custom.scss 文件?

回答by SUNGRAIZ FARYAD

Bootstrap 4 is a big hit. They have completely rewritten it. So, You can override the variables very easily. Just create a _custom-variables.scssfile and import it before _variables.scssfile in bootstrap.scssas shown below. enter image description here

Bootstrap 4 大受欢迎。他们已经完全改写了它。因此,您可以非常轻松地覆盖变量。只需创建一个 _custom-variables.scss文件并将其导入到bootstrap.scss 中的_variables.scss文件之前,如下所示。 在此处输入图片说明

Copy the variable which you want to override, paste it in _custom-variables.scssand change the value as you want. Also remove the !default attribute. Compile it again and done. The !default attribute is reverse of !important. It will take the value of previously declared variable.

复制要覆盖的变量,将其粘贴到_custom-variables.scss并根据需要更改值。还要删除 !default 属性。再次编译并完成。!default 属性与 !important 相反。它将采用先前声明的变量的值。