Last active
December 26, 2015 13:29
-
-
Save skube/7159055 to your computer and use it in GitHub Desktop.
CSS: Basic high resolution targeting
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
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