Last active
September 30, 2015 10:18
-
-
Save hellosmithy/1769124 to your computer and use it in GitHub Desktop.
Cross-browser alpha transparent background CSS (rgba) Stylus mixin
This file contains 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
// background transparency | |
background-transparency(color, alpha = 1) | |
ms-color = argb(color, alpha) | |
background rgb(color) | |
background rgba(color, alpha) | |
.lt-ie8 & | |
zoom 1 | |
.lt-ie9 & | |
background transparent | |
filter s('progid:DXImageTransform.Microsoft.gradient(startColorstr=%s,endColorstr=%s)', ms-color, ms-color) | |
&:nth-child(n) | |
filter none | |
hex(decimal) | |
hex-value = ('0') ('1') ('2') ('3') ('4') ('5') ('6') ('7') ('8') ('9') ('A') ('B') ('C') ('D') ('E') ('F') | |
unquote(hex-value[floor(decimal / 16)] + hex-value[floor(decimal % 16)]) | |
argb(color, alpha = 1) | |
unquote('#') + hex(alpha * 255) + hex(red(color)) + hex(green(color)) + hex(blue(color)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added improvements from https://gist.github.com/adunkman/2580972