Skip to content

Instantly share code, notes, and snippets.

@brianmcallister
Created July 5, 2012 14:51
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 brianmcallister/3054122 to your computer and use it in GitHub Desktop.
Save brianmcallister/3054122 to your computer and use it in GitHub Desktop.
Set a background image sized for retina screens, with an option to use the image url or an inline image.
/*
Set a background image sized for retina screens, with an option to use the image url or an inline image.
@param {String} $image Image to use.
@param {String} [$type] Type of image url to use. Default to an inline image.
*/
@mixin retina-image($image, $type: 'inline') {
@include hide-text;
@if $type != 'inline' and $type != 'url' {
@warn 'Unknown usage type. Falling back to "url"';
$type: 'url';
}
width: image-width($image) / 2;
height: image-height($image) / 2;
@if $type == 'inline' {
background: center center no-repeat inline-image($image);
} @else if $type == 'url' {
background: center center no-repeat image-url($image);
}
background-size: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment