Created
July 5, 2012 14:51
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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