如何在Sass中覆盖Bootstrap变量? [英] How to override bootstrap variables in sass?

查看:86
本文介绍了如何在Sass中覆盖Bootstrap变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

推荐答案

引导程序4很受欢迎.他们已经完全重写了它.因此,您可以轻松地覆盖变量.只需创建一个 _custom-variables.scss 文件,然后将其导入 bootstrap.scss 中的 _variables.scss 文件之前,如下所示.

Bootstrap 4 is a big hit. They have completely rewritten it. So, You can override the variables very easily. Just create a _custom-variables.scss file and import it before _variables.scss file in bootstrap.scss as shown below.

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

Copy the variable which you want to override, paste it in _custom-variables.scss and 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.

这篇关于如何在Sass中覆盖Bootstrap变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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