簡體   English   中英

編譯為 CSS 時如何覆蓋 SCSS 變量

[英]How to overwrite SCSS variables when compiling to CSS

我正在嘗試使用基於 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。 顏色規范無處可見,盡管根據文檔( 官方指南)和 jqtouch.scss 文件中的變量是明確正確的,我導入該文件用於服裝化。

我在 Windows 機器上運行 Sass 3.2.9 和 Compass 0.12.2。

我已經嘗試使用更多變量和不同的文件導入,但結果總是,我的覆蓋值沒有被合並。

指南針的 ruby​​ 配置文件似乎不可疑。

有沒有人知道這個過程中出了什么問題,以至於我的覆蓋值被忽略了?

你設置它的顏色已經被使用之后 基本上,您要做的是:

$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';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM