Skip to content

Instantly share code, notes, and snippets.

@samme
Created August 10, 2013 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samme/6202694 to your computer and use it in GitHub Desktop.
Save samme/6202694 to your computer and use it in GitHub Desktop.
Compass mixins for the CSS4 `image-rendering` property with some cross-browser equivalents
=image-rendering($hint)
@if $hint == 'crisp-edges'
@if $legacy-support-for-ie8 or $legacy-support-for-ie7
-ms-interpolation-mode: bilinear
@if $experimental-support-for-webkit
image-rendering: -webkit-optimize-contrast
+experimental-value(image-rendering, crisp-edges, $moz: $experimental-support-for-mozilla, $webkit: false, $o: $experimental-support-for-opera, $ms : false, $khtml: false, $official: true)
@else if $hint == 'pixelated'
@if $legacy-support-for-ie8 or $legacy-support-for-ie7
-ms-interpolation-mode: bilinear
image-rendering: pixelated
@else if $hint == 'optimizeQuality' or $hint == 'optimizeSpeed'
@warn "#{$hint} is deprecated in CSS4 http://dev.w3.org/csswg/css-images/#the-image-rendering"
image-rendering: $hint
@else if $hint == 'auto'
image-rendering: $hint
@else
@warn "'#{$hint} was ignored because it's not a valid property value for image-rendering (auto, crisp-edges, pixelated) http://dev.w3.org/csswg/css-images/#the-image-rendering"
=crisp-edges
+image-rendering('crisp-edges')
=pixelated
+image-rendering('pixelated')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment