Search code examples
firefoxexplorerfavorites

Escape syntax for LESS whilst using -ms-filter: "codeNeedsVar";


I needed to be able to get a less variable into

/* Opacity */
.opacity(@opacity: 0.35){
    -moz-opacity: @opacity;
    -khtml-opacity: @opacity;
    -webkit-opacity: @opacity;
    opacity: @opacity;
    @ieOpacity: @opacity * 100;
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=@ieOpacity)";
    filter: ~"alpha(opacity=@ieOpacity)";
}

When this is complied the code would look like this in the .css file (Opacity=@ieOpacity)


Solution

  • The answer is simple, add @{var} so that less knows its a variable and not text

    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=@{ieOpacity})";