当我在ColorZilla上制作一条线性渐变时,我会获取以下类似于scss的代码:
@include background-image(linear-gradient(top, #659adc 0%,#004ca2 100%));
生成以下CSS:
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #659adc), color-stop(100%, #004ca2));
background-image: -webkit-linear-gradient(top, #659adc 0%, #004ca2 100%);
background-image: -o-linear-gradient(top, #659adc 0%, #004ca2 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(top), color-stop(0%, #659adc), to(#004ca2));
background-image: linear-gradient(top, #659adc 0%, #004ca2 100%);
而且这些都不能在Firefox中使用。所以我进行了一些调整,并添加了我知道在Firefox中有效的内容:
@include background-image(linear-gradient(to bottom, #659adc 0%,#004ca2 100%)); //notice the 'to bottom'
现在这是生成的 CSS:
background-image: -webkit-gradient(linear, to bottom, to top, color-stop(0%, #659adc), color-stop(100%, #004ca2));
background-image: -webkit-linear-gradient(to bottom, #659adc 0%, #004ca2 100%);
background-image: -o-linear-gradient(to bottom, #659adc 0%, #004ca2 100%);
background-image: -webkit-gradient(linear, left top, left bottom, from(#659adc), to(#004ca2));
background-image: -webkit-linear-gradient(top, #659adc 0%, #004ca2 100%);
background-image: -o-linear-gradient(top, #659adc 0%, #004ca2 100%);
background-image: linear-gradient(to bottom, #659adc 0%, #004ca2 100%);
在Firefox中可以正常显示,但compass任务会出现以下错误:
无法确定“to”的相反位置。
有什么想法吗?如何实现跨浏览器的scss线性渐变?
background-image: linear-gradient(#659adc, #004ca2)
就可以正常工作,因为渐变默认从上到下。 - Josiah