简体   繁体   English

较少线性梯度滤波器

[英]less linear gradient filter

I have a problem with mixin in less. 我在混入较少的问题。

I less file I have. 我少了文件。

.gradient(@startColor, @endColor) {
  background: @startColor;
  background: linear-gradient(to bottom, @startColor 0%,@endColor 100%); 
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='@{startColor}', endColorstr='@{endColor}',GradientType=1 );  
}

#nav {
  .gradient(#fff,#e2ebef);
}

.btn {  
  .gradient(#f2f2f2, #e4e4e4);
}

After compile i get this: 编译后我得到这个:

#nav {
  background: #ffffff;
  background: linear-gradient(to bottom, #ffffff 0%, #e2ebef 100%);
  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#e2ebef', GradientType=1);
}
.btn {
  background: #f2f2f2;
  background: linear-gradient(to bottom, #f2f2f2 0%, #e4e4e4 100%);
  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#e2ebef', GradientType=1);
}

Why in the .btn's filter there is the same color as in a #nav? 为什么.btn过滤器中的颜色与#nav中的颜色相同? I have googled for sulution, but didn't find anything which solves this problem. 我已经用谷歌搜索了解决方法,但是没有找到任何可以解决这个问题的方法。

So... Is there another solution than pasting manually colors in generated css file? 所以...除了在生成的CSS文件中手动粘贴颜色以外,还有其他解决方案吗?

Change the filter property to read as such: 将filter属性更改为:

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

This automatically escapes much of the nonsense in the filter property and allows for the variables within that string to be output correctly. 这会自动转义filter属性中的许多废话,并允许正确输出该字符串中的变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM