Created
June 23, 2014 05:01
-
-
Save charliefmoran/742bbcf8279186a264fa to your computer and use it in GitHub Desktop.
SCSS Mixin for Cross-Browser Semi-Transparent Background
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @mixin semi-transparent-background($color, $opacity) { | |
| $red: red($color); | |
| $green: green($color); | |
| $blue: blue($color); | |
| $hex_color: rgb($red,$green,$blue); | |
| $hex_color_with_alpha: rgba($color,$opacity); | |
| $ie_hex_color: ie-hex-str($hex_color_with_alpha); | |
| background: $hex_color; | |
| background: $hex_color_with_alpha; | |
| -ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie_hex_color}, endColorstr=#{$ie_hex_color}); | |
| filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie_hex_color}, endColorstr=#{$ie_hex_color}); | |
| } | |
| // Background: http://sass-lang.com/documentation/Sass/Script/Functions.html#ie_hex_str-instance_method | |
| // For any element that you want a semi-transparent background, include this mixin | |
| // For ie, you also need to add the following to your document head and add the .semi-transparent class to your same container | |
| // <!--[if lt IE 10 ]> <style>.semi-transparent {background: transparent}</style> <![endif]--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment