無論何時使用梯度函數(線性/徑向),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的功能版本。
剛纔宣佈缺失的功能有什麼問題? – cimmanon
我不清楚如何定義一個sass函數,它會返回與函數名稱相同的東西。正如你在下面建議的那樣,使用插值#{}是我錯過的技巧。 –