Skip to content

Instantly share code, notes, and snippets.

@zhaiduo
Forked from marcedwards/high-dpi-media.css
Created May 8, 2018 15:27
Show Gist options
  • Save zhaiduo/30384c429d3809ee2d5f335e52856d5b to your computer and use it in GitHub Desktop.
Save zhaiduo/30384c429d3809ee2d5f335e52856d5b to your computer and use it in GitHub Desktop.
A CSS media query that captures almost all high DPI aware devices.
/* ---------------------------------------------------------- */
/* */
/* A media query that captures: */
/* */
/* - Retina iOS devices */
/* - Retina Macs running Safari */
/* - High DPI Windows PCs running IE 8 and above */
/* - Low DPI Windows PCs running IE, zoomed in */
/* - Low DPI Windows PCs and Macs running Firefox, zoomed in */
/* - Android hdpi devices and above */
/* - Android tvdpi devices, including Google Nexus 7 */
/* - Chrome running on high DPI Macs and PCs */
/* - Opera running on high DPI Macs, PCs and mobile devices */
/* */
/* Please note that that this code assumes you'll swap a */
/* 2× version of your images. If you'd like to supply */
/* finer increments, other thresholds might be appropriate. */
/* */
/* A test for CSS pixel densites can be found here: */
/* http://bjango.com/articles/min-device-pixel-ratio/ */
/* */
/* @marcedwards from @bjango */
/* */
/* ---------------------------------------------------------- */
@media only screen and (-webkit-min-device-pixel-ratio: 1.3),
only screen and (-o-min-device-pixel-ratio: 13/10),
only screen and (min-resolution: 120dpi)
{
/* Your code to swap higher DPI images */
}
@zhaiduo
Copy link
Author

zhaiduo commented May 8, 2018

--   | -webkit-min-device-pixel-ratio   |
nothin’
  |
1.0
  |
1.1
  |
1.2
  |
1.3
  |
1.4
  |
1.5
  |
1.6
  |
1.7
  |
1.8
  |
1.9
  |
2.0
  |
2.1
  |
2.2
  |
2.3
  |
2.4
  |
2.5
  |
2.6
  |
2.7
  |
2.8
  |
2.9
  |
3.0
  |
  |     |
  | -o-min-device-pixel-ratio   |
nothin’
  |
1.0
  |
1.1
  |
1.2
  |
1.3
  |
1.4
  |
1.5
  |
1.6
  |
1.7
  |
1.8
  |
1.9
  |
2.0
  |
2.1
  |
2.2
  |
2.3
  |
2.4
  |
2.5
  |
2.6
  |
2.7
  |
2.8
  |
2.9
  |
3.0
  |
  |     |
  | min-resolution (dpi)   |
nothin’
  |
96dpi
  |
105dpi
  |
115dpi
  |
125dpi
  |
135dpi
  |
144dpi
  |
154dpi
  |
163dpi
  |
173dpi
  |
182dpi
  |
192dpi
  |
202dpi
  |
211dpi
  |
221dpi
  |
230dpi
  |
240dpi
  |
250dpi
  |
259dpi
  |
267dpi
  |
278dpi
  |
288dpi
  |
  |     |
  | min-resolution (dppx)   |
nothin’
  |
1.0dppx
  |
1.1dppx
  |
1.2dppx
  |
1.3dppx
  |
1.4dppx
  |
1.5dppx
  |
1.6dppx
  |
1.7dppx
  |
1.8dppx
  |
1.9dppx
  |
2.0dppx
  |
2.1dppx
  |
2.2dppx
  |
2.3dppx
  |
2.4dppx
  |
2.5dppx
  |
2.6dppx
  |
2.7dppx
  |
2.8dppx
  |
2.9dppx
  |
3.0dppx
  |

@zhaiduo
Copy link
Author

zhaiduo commented May 8, 2018

Devices with -webkit-min-device-pixel-ratio: 1.0

--   |

  | All non-Retina Macs
  | Apple iPhone (1st generation)
  | Apple iPhone 3G
  | Apple iPhone 3GS
  | Apple iPad (1st generation)
  | Apple iPad 2
  | Apple iPad mini (1st generation)
  | Acer Iconia A500
  | Samsung Galaxy Tab 10.1
  | Samsung Galaxy S
  |

  |     |

Devices with -webkit-min-device-pixel-ratio: 1.3

  |

  | Asus MemoPad HD 7
  | Google Nexus 7 (2012 model)
  |

  |     |

Devices with -webkit-min-device-pixel-ratio: 1.4

  |

  | Nokia Lumia 520
  |

  |     |

Devices with -webkit-min-device-pixel-ratio: 1.5

  |

  | Google Nexus S
  | HTC Desire
  | HTC Desire HD
  | HTC Incredible S
  | HTC Velocity
  | HTC Sensation
  | Kindle Fire HD
  | Samsung Galaxy S II
  | Sony Xperia Tablet Z
  | Sony Xperia U
  |

  |     |

Devices with -webkit-min-device-pixel-ratio: 2.0

  |

  | All Macs with Retina displays
  | Apple iPhone 4
  | Apple iPhone 4S
  | Apple iPhone 5
  | Apple iPhone 5c
  | Apple iPhone 5s
  | Apple iPhone 6
  | Apple iPhone 6s
  | Apple iPhone 7
  | Apple iPad (3rd generation)
  | Apple iPad 4
  | Apple iPad Air
  | Apple iPad mini (2rd generation)
  | HTC One X
  | Google Galaxy Nexus
  | Google Nexus 4
  | Google Nexus 7 (2013 model)
  | Google Nexus 10
  | Motorola Moto X
  | Samsung Galaxy S III
  | Samsung Galaxy Note II
  | Sony Xperia S
  | Sony Xperia T
  |

  |     |

Devices with -webkit-min-device-pixel-ratio: 2.6

  |

  | Nokia Lumia 930
  | Google Nexus 5X
  |

  |     |

Devices with -webkit-min-device-pixel-ratio: 3.0

  |

  | HTC One (M7)
  | HTC Butterfly
  | Huawei Honor 6
  | Huawei Mate 9
  | Apple iPhone 6 Plus
  | Apple iPhone 6s Plus
  | Apple iPhone 7 Plus
  | LG G2
  | Nexus 5
  | Nexus 6
  | Motorola Moto G4
  | OnePlus One
  | Oppo Find 7 (X9076)
  | Samsung Galaxy S4
  | Samsung Galaxy Note 3
  | Samsung Galaxy Note 4
  | Sony Xperia Z
  | Xiaomi Mi 3
  |

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