带有IE FIlter Alpha不透明度CSS的LESSCSS方法 [英] LESSCSS method with IE FIlter Alpha Opacity CSS

查看:50
本文介绍了带有IE FIlter Alpha不透明度CSS的LESSCSS方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 LESSCSS .我正在尝试创建不透明度的方法:

I am using LESSCSS. I'm trying to create a method for opacity:

.opacity (@opacity) 
{
    opacity: @opacity;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=(@opacity * 100))"; 
    filter: alpha(opacity = (@opacity * 100));
}

因此,如果我使用以下方式调用它:

So, If I call it using:

h1 {
  .opacity(.5);
}

我希望它输出:

h1 {
  opacity: .5;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
  filter: alpha(opacity = 50);
}

但是,LESS会抛出错误:

But instead, LESS throws the error:

Expected '}' on line 30 in file '/Content/styles/style.less.css':
 [29]:     -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=(@opacity * 100))"; 
 [30]:     filter: alpha(opacity = (@opacity * 100));
       ----^
 [31]: }

我在做什么错了?

推荐答案

在无点的情况下,执行此操作. (我不建议您使用脚本标签-它们很丑陋,特定于语言,不受dotless的支持.)

In dotless, do this. (I would NOT recommend script tags - they are ugly, language specific and not supported by dotless).

.opacity (@opacity) {
    @opacityPercentage: @opacity * 100;
    opacity: @opacity;
    -ms-filter: ~"progid:DXImageTransform.Microsoft.Alpha(opacity=(@{opacityPercentage}))"; 
    filter: ~"alpha(opacity = (@{opacityPercentage}))";
}

在无点1.2.3中(当它在几周内发布,或者在github头上发布时,您应该可以做到这一点...

in dotless 1.2.3 (when it is released in a couple of weeks, or github head, you should be able to do this...

.opacity (@opacity) {
    @opacityPercentage: @opacity * 100;
    opacity: @opacity;
    -ms-filter: progid:DXImageTransform.Microsoft.Alpha(opacity=(@opacityPercentage)); 
    filter: alpha(opacity = (@opacityPercentage));
}

并重新:来自Mathletics的评论,dotless并不是最糟糕的编译器".它匹配less.js到1.1.5,不久将成为1.2.2,并且针对less.js的600个错误中的许多都已修复.在无点.您可能已经在8个月前使用了dotless,但情况有所变化,并且错误已修复.dotless还对注释和变量作用域提供了更好的支持.

and re: the comment from Mathletics, dotless is not "the worst compiler".. It matches less.js up to 1.1.5, soon to be 1.2.2 and many of the 600 bugs against less.js are fixed in dotless. You may have used dotless over 8 months ago, but things change and bugs are fixed... dotless also has better support for comments and variable scoping.

这篇关于带有IE FIlter Alpha不透明度CSS的LESSCSS方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆