Skip to content

Instantly share code, notes, and snippets.

@adamstac
Forked from jamesfinley/Hi-res Graphic Mixin
Created September 17, 2011 14:07
Show Gist options
  • Save adamstac/1223970 to your computer and use it in GitHub Desktop.
Save adamstac/1223970 to your computer and use it in GitHub Desktop.
A simple way to include both low-res and hi-res graphics for iOS/Desktop/etc.
@mixin hires-graphic($file, $type, $width, $height) {
$file_name: $file + '.' + $type;
$retina_name: $file + '_2x.' + $type;
@media (-webkit-min-device-pixel-ratio: 2) {
& {
background-image: url('../images/' + $retina_name);
-webkit-background-size: $width $height;
}
}
}
/*
Example Use:
.facebook {
display: block;
width: 20px;
height: 20px;
background-repeat: no-repeat;
@include hires-graphic('icon_facebook', 'png', 20px, 20px);
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment