如何在编译CSS时覆盖SCSS变量

时间:2013-06-13 14:31:29

标签: sass compass-sass jqtouch

我正在尝试使用基于SASS和COMPASS的jqtouch主题。我有一个文件custom.scss,其中包含最简单的代码,一个导入和一个要覆盖的变量:

@import 'jqtouch';

// Override variables
$base-color: #fe892a;/* The default base which is later used for toolbar, list, and button backgrounds.*/

当我现在将scss文件编译为css时,它基本上只会生成带有我的文件名的jqtouch css。颜色规范无处可见,尽管变量对于每个文档(Official Guide)和jqtouch.scss文件都是正确的,我将导入该文件用于costumizing。

我在Windows机器上运行Sass 3.2.9和Compass 0.12.2。

我已尝试使用更多变量和不同的文件导入,但结果始终是,我的覆盖值未合并。

指南针的ruby配置文件似乎是不可靠的。

有没有人知道过程中出了什么问题,以便忽略我的覆盖值?

1 个答案:

答案 0 :(得分:85)

您已经使用之后设置颜色。基本上,你要做的是:

$color: red;

.foo {
    background: $color;
}

$color: green;

根据jqtouch的编写方式,您可能根本无法修改颜色。您需要将变量设置为默认值才能提前覆盖它们:

$color: green;
$color: red !default; // red is only used if $color is not already set

.foo {
    background: $color; // color is green
}

所以你的代码应该这样编写:

// Override variables
$base-color: #fe892a;/* The default base which is later used for toolbar, list, and button backgrounds.*/

@import 'jqtouch';