LESSCSS method with IE FIlter Alpha Opacity CSS

后端 未结 5 1345
终归单人心
终归单人心 2021-02-04 00:19

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

.opacity (@opacity) 
{
    opacity: @opacity;
    -ms-filter: \"progid:DXImageTransform.Microsof         


        
5条回答
  •  暖寄归人
    2021-02-04 00:57

    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}))";
    }
    

    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));
    }
    

    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.

提交回复
热议问题