Skip to content

Instantly share code, notes, and snippets.

@GregWallace
Created April 9, 2014 13:19
Show Gist options
  • Select an option

  • Save GregWallace/10269557 to your computer and use it in GitHub Desktop.

Select an option

Save GregWallace/10269557 to your computer and use it in GitHub Desktop.
Retina CSS example. Setting ackground size ensures 2x will scale to fit original image
// reference url: http://stackoverflow.com/questions/16154494/retina-displays-high-res-background-images
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.box{
background:url('images/box-bg@2x.png') no-repeat top left;
background-size: 200px 200px; // change to suit image dimensions for 1x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment