Skip to content

Instantly share code, notes, and snippets.

@skube
Last active December 26, 2015 13:29
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 skube/7159055 to your computer and use it in GitHub Desktop.
Save skube/7159055 to your computer and use it in GitHub Desktop.
CSS: Basic high resolution targeting
body {background-image: url('foo.png');}
/* DPR (device px ratio) of 2*/
@media screen and (-webkit-device-pixel-ratio: 2) {
body {background-image: url('foo-hi-res.png')}
}
/*OR better DPI (dots/inch) */
@media screen and (resolution: 96dpi) {
body {background-image: url('foo.png');}
}
@media screen and (min-resolution:192dpi) {
body {background-image: url('foo-hi-res.png')}
}
/* OR another way DPPX (dots/px) */
@media screen and (min-resolution: 2dppx) {
body {background-image: url('foo-hi-res.png')}
}
/* OR safest to cover legacy proprietary webkit */
@media screen and (min-resolution: 2ddpx), screen and (-webkit-device-pixel-ratio: 2) {
body {background-image: url('foo-hi-res.png'); background-size: cover}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment