Created
March 18, 2012 17:49
-
-
Save richthegeek/2078534 to your computer and use it in GitHub Desktop.
Safe color 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
@function mix-alpha($color, $bg) { | |
@return mix(opacify($color, 1), opacify($bg, 1), alpha($color) * 100); | |
} | |
@mixin safe-color($color, $bg) { | |
background: mix-alpha($color, $bg); | |
background: $color; | |
} | |
body { | |
@include safe-color(rgba(255, 0, 0, 0.5), #000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
body { background: #7f0000; background: rgba(255, 0, 0, 0.5); }