适用于IE8的Mixins Gradient

时间:2015-07-27 11:13:23

标签: css3 less mixins

我正在尝试为IE8中的wotk制作一些LESS Mixin,我知道我可以在IE8中使用渐变这样

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */

这是juwt的例子,但是我需要制作一些自定义mixin,它将为IE8创建,这就是我所拥有的CSS

 background-image: linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
    background-image: -o-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
    background-image: -moz-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
    background-image: -webkit-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);
    background-image: -ms-linear-gradient(bottom, rgba(0,0,0, 0) 50%, rgba(255,255,255, 0.08) 0%);

我需要的是修改我创建的LESS mixins

.gradient (@startColor: #eee, @endColor: white) {
    background-color: @startColor;
    background: -webkit-gradient(linear, left top, left bottom, from(@startColor), to(@endColor));
    background: -webkit-linear-gradient(top, @startColor, @endColor);
    background: -moz-linear-gradient(top, @startColor, @endColor);
    background: -ms-linear-gradient(top, @startColor, @endColor);
    background: -o-linear-gradient(top, @startColor, @endColor);
}

支持IE8:)

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='@startColor', endColorstr='@endColor',GradientType=0 ); /* IE6-9 */

但问题出在这里 的' @ startColor'

在括号中,它无法识别变量

1 个答案:

答案 0 :(得分:-1)

传统的LESS编译器不接受filter属性并会引发错误。您只需使用LESS Escaping来解决此问题。您需要做的就是在渐变中添加以下行,它应该可以正常工作。

filter: ~”progid:DXImageTransform.Microsoft.gradient(startColorstr='@{startColor},
endColorstr='@{endColor})”;

此行将显示在代码中。

相关问题