Skip to content

Instantly share code, notes, and snippets.

@jamesfinley
Created August 10, 2011 13:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamesfinley/1136844 to your computer and use it in GitHub Desktop.
Save jamesfinley/1136844 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);
}
*/
@adamstac
Copy link

I love how simple this can be. Why don't you turn this into a full on repo and I'll help you with it like I'm helping bitmanic with rem?

@adamstac
Copy link

I really want to work on this. Please turn this into a full on repo and add me as collaborator :) I'd do it, but then the project would be under my namespace vs yours.

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