Skip to content

Instantly share code, notes, and snippets.

@bergantine
Last active May 23, 2017 20:07
Show Gist options
  • Save bergantine/2114328 to your computer and use it in GitHub Desktop.
Save bergantine/2114328 to your computer and use it in GitHub Desktop.
CSS and JS to detect a retina display. #css #javascript #retina #responsive
<style>
/* from http://www.mobilexweb.com/blog/ios-5-1-new-ipad-web-developers */
@media screen and (-webkit-device-pixel-ratio: 2) {
/* retina display */
}
</style>
<script>
// from https://developer.mozilla.org/en/DOM/window.matchMedia
if (window.matchMedia("(-webkit-device-pixel-ratio: 2)").matches) {
/* retina display */
}
</script>
@rdp
Copy link

rdp commented May 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment