Skip to content

Instantly share code, notes, and snippets.

@kwoktung
Forked from irazasyed/readme.md
Created August 16, 2018 16:22
Show Gist options
  • Save kwoktung/067009eedb101c5a3d69de7a5b916ba7 to your computer and use it in GitHub Desktop.
Save kwoktung/067009eedb101c5a3d69de7a5b916ba7 to your computer and use it in GitHub Desktop.
CSS: Retina Display Media Query

Retina Display Media Query Example:

===

CSS Code for Normal and Retina:

#logo{
    background-image: url(logo.png);
    background-size: 185px 75px;
    background-repeat: no-repeat;
    display: block;
    width: 185px;
    height: 75px;
}

/* Retina Display Media Query */
@media
(-webkit-min-device-pixel-ratio: 1.5),
(   min--moz-device-pixel-ratio: 1.5),
(     -o-min-device-pixel-ratio: 3/2),
(        min-device-pixel-ratio: 1.5),
(                min-resolution: 1.5dppx) {
  #logo  {
    background: url(logo@2x.png) no-repeat center;
    background-size: 185px 75px;
    width: 185px;
    height: 75px;
  }
}
@media
(-webkit-min-device-pixel-ratio: 1.5),
( min--moz-device-pixel-ratio: 1.5),
( -o-min-device-pixel-ratio: 3/2),
( min-device-pixel-ratio: 1.5),
( min-resolution: 1.5dppx) {
/*
CSS FOR RETINA DISPLAY
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment