2015-11-18 40 views
0

我們使用Rails + Sprockets + Compass。指南針定義了一個linear-gradient function,與同名的css function相沖突。我可以刪除或忽略定義的sass功能嗎?

我們的scss文件做了@import "compass"之後,有沒有辦法刪除Compass的線性漸變函數,以便我可以在css中插入原始的線性漸變?

我知道我可以重新定義函數,但我仍然無法弄清楚如何重新定義它,以便我可以插入原始線性漸變。我想完全刪除該功能。

問題是我們正在遷移到libsass,這意味着Compass的基於Ruby的函數不再有效。因此,這

@import "compass"; 
.tmp { 
    button-background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

,我想是原樣輸出,編譯成這樣:

.tmp { 
    button-background: _linear-gradient_legacy(compact(to bottom), #fdefd4, #fdc154...); 
} 

其中_linear-gradient_legacy是一個基於Ruby的羅盤功能,將不再下libsass擴大。

+0

剛纔宣佈缺失的功能有什麼問題? – cimmanon

+0

我不清楚如何定義一個sass函數,它會返回與函數名稱相同的東西。正如你在下面建議的那樣,使用插值#{}是我錯過的技巧。 –

回答

0

無論何時使用梯度函數(線性/徑向),Compass都希望使用提供的背景和背景圖像函數。這就是你如何得到你的前綴。所涉及的函數之所以用Ruby編寫,是因爲您可以獲得不支持漸變的瀏覽器的SVG漸變。

如果你想絕對沒有這一點,只是重新定義像這樣的功能:

@import "compass/css3"; 

.foo { 
    background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

.bar { 
    @include background(linear-gradient(to bottom, #fdefd4, #fdc154)); 
} 

輸出:

.foo { 
    background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

.bar { 
    background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuNSIgeTE9IjAuMCIgeDI9IjAuNSIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZkZWZkNCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2ZkYzE1NCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); 
    background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fdefd4), color-stop(100%, #fdc154)); 
    background: -moz-linear-gradient(top, #fdefd4, #fdc154); 
    background: -webkit-linear-gradient(top, #fdefd4, #fdc154); 
    background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

後:

@function linear-gradient($options...) { 
    @return #{'linear-gradient(#{$options})'}; 
} 

重新聲明函數之前

@import "compass/css3"; 

@function linear-gradient($options...) { 
    @return #{'linear-gradient(#{$options})'}; 
} 

.foo { 
    background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

.bar { 
    @include background(linear-gradient(to bottom, #fdefd4, #fdc154)); 
} 

輸出:

.foo { 
    background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

.bar { 
    background: linear-gradient(to bottom, #fdefd4, #fdc154); 
} 

否則,你就必須實現自己的薩斯Ruby的功能版本。

相關問題