mca5xw
Last Updated: February 25, 2016
·
13.17K
· shavit

SASS Opacity Mixin

CSS Opacity SASS MIxin For IE, FireFox, Chrome and Safari

@mixin Opacity($value){
  $IEValue: $value*100;
  opacity: $value;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity="+$IEValue+")";
  filter: alpha(opacity=$IEValue);
}

How To Use

img.preload{
    @include Opacity(0);

    &.complete{
        @include Opacity(1);
    }
}

http://conpanna.net

3 Responses
Add your response

14706

Well done, thank you

over 1 year ago ·
14765

Good job on this. I was making my own but was thinking i'd better check up on some other alternatives.

over 1 year ago ·
15290

Thanks!

I changed the casing to fit our conventions, maybe suits someone else:

@mixin opacity($value){
  $ie-value: $value * 100;
  opacity: $value;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity="+$ie-value+")";
  filter: alpha(opacity=$ie-value);
}
over 1 year ago ·