Skip to content

Instantly share code, notes, and snippets.

@bcinarli
Created June 7, 2014 17:59
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 bcinarli/7fe71c7daae450b6774a to your computer and use it in GitHub Desktop.
Save bcinarli/7fe71c7daae450b6774a to your computer and use it in GitHub Desktop.
Retina background image. Uses a $retina-suffix variables for retina & normal image files
/* @author Bilal Cinarli */
/** -------------------------------------------
Media Query Mixins
------------------------------------------- **/
/**
* Retina Image
*/
@mixin retina-image($image, $ext: 'png'){
background-image: url('#{$images}#{$image}.#{$ext}');
@include retina(){
background-image: url('#{$images}#{$image}#{$retina-suffix}.#{$ext}');
}
}
/**
* Retina
*/
@mixin retina($ratio: 1.5){
$dpi: 96*$ratio;
@media only screen and (-webkit-min-device-pixel-ratio: $ratio),
only screen and (min--moz-device-pixel-ratio: $ratio),
only screen and (-o-min-device-pixel-ratio: $ratio/1),
only screen and (min-resolution: #{$dpi}dpi),
only screen and (min-resolution: #{$ratio}dppx) {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment