gpt4 book ai didi

css - 在 bootstrap-sass 中访问文件

转载 作者:行者123 更新时间:2023-11-28 16:31:42 26 4
gpt4 key购买 nike

我正在处理一个 Rails 元素,我需要在 Twitter Bootstrap 的 CSS 中自定义几个变量来禁用最终看起来很奇怪的响应功能。

为此,我知道我需要进入 bootstrap-sass 文件夹来访问变量文件,因此,我从命令行运行:

 $cd `bundle show bootstrap-sass`

然后我运行:

 $find vendor/assets/stylesheets

到目前为止一切顺利。我在/assets 中看到了所有样式表的列表,其中包括我想要进入的 vendor/assets/stylesheets/bootstrap/_variables.scss

我尝试运行 $open vendor/assets/stylesheets/bootstrap/_variables.scss,但它返回错误:

 No application knows how to open /usr/local/rvm/gems/ruby-2.0.0-p451/gems/bootstrap-sass-3.1.1.0/vendor/assets/stylesheets/bootstrap/_variables.scss.

关于如何打开和编辑此文件的任何想法?

最佳答案

通常,您永远不想覆盖硬编码(默认)变量;你想override他们:

#app/assets/stylesheets/application.sass
@import custom_vars #-> your own variables file
@import bootstrap

#app/assets/stylehseets/custom_vars.sass
$override_1: "x"

In Sass variables need to be defined before they can be used - in this case if you want to redefine a variable it needs to be done before the @import directive so the Bootstrap scss files can make use of it.

只需在调用@import bootstrap 之前声明自定义变量,它将使用您的值而不是硬编码的值。


这与 vars in bootstrap 的事实相辅相成用 !default 声明开关——意思是they're meant to be overridden :

You can assign to variables if they aren’t already assigned by adding the !default flag to the end of the value. This means that if the variable has already been assigned, it won’t be re-assigned, but if it doesn’t have a value yet, it will be given one

关于css - 在 bootstrap-sass 中访问文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35219434/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com