Skip to content

Instantly share code, notes, and snippets.

@robfletcher
Created May 17, 2013 08:45
Show Gist options
  • Select an option

  • Save robfletcher/5597817 to your computer and use it in GitHub Desktop.

Select an option

Save robfletcher/5597817 to your computer and use it in GitHub Desktop.
SASS mixin that uses modernizr to output fallback color property for browsers that don't support RGBA.
/*
* Outputs a color property with an opaque fallback for browsers that do not support RGBA.
*/
@mixin safe-rgba($property, $color, $fallback-color: opacify($color, 1)) {
@if opacity($color) == 1 {
#{$property}: $color;
} @else {
#{$property}: $fallback-color;
.rgba & {
#{$property}: $color;
}
}
}
@robfletcher

Copy link
Copy Markdown
Author

That's great, much more thorough than my version. I don't think modernizr does have a detect for the on IE filters, no.

@twome

twome commented May 18, 2013

Copy link
Copy Markdown

Glad to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment