Skip to content

Instantly share code, notes, and snippets.

@tylerpearson
Last active December 10, 2015 19:19
Show Gist options
  • Save tylerpearson/4480482 to your computer and use it in GitHub Desktop.
Save tylerpearson/4480482 to your computer and use it in GitHub Desktop.
LESS mixin to make optimization for Retina and high-dpi screens easier.
// media queries are escaped to prevent potential LESS rendering errors
// adapted from http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
@mediaRetina: ~"(min-resolution: 124dpi), (-webkit-min-device-pixel-ratio: 1.3), (min--moz-device-pixel-ratio: 1.3), (-o-min-device-pixel-ratio: 4/3), (min-device-pixel-ratio: 1.3), (min-resolution: 1.3dppx)";
.image-2x(@image, @width, @height) {
@media @mediaRetina {
background-image: url('@{image}');
background-size: @width @height;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment