Resolution confused me until I investigated the units behind it.
- 2 unit sets exist and differ at a fixed scale: device units and CSS units.
- Resolution is calculated as the number of dots that can fit along a particular CSS length.
- Unit conversion:
- CSS has relative and absolute lengths. In normal zoom:
- dppx is equivalent to
device-pixel-ratio
.
devicePixelRatio
definition differs by platform.
- Media queries can target
min-resolution
. Use with care for speed.
Unit |
Definition |
Measures |
dot |
device pixel |
length |
px |
CSS pixel |
length |
cm |
CSS centimeter |
length |
in |
CSS inch |
length |
dppx |
|
resolution |
dpcm |
|
resolution |
dpi |
|
resolution |
Method |
Output (current device) |
Unit |
res.dppx() |
? |
dppx |
res.dpi() |
? |
dpi |
res.dpcm() |
? |
dpcm |
Input |
Output (current device) |
Notes |
window.devicePixelRatio |
? |
draft, quirks |
window.matchMedia |
? |
standard |
window.msMatchMedia |
? |
IE10 PP3 |
window.screen.deviceXDPI |
? |
IE, zoom-relative |
window.screen.deviceYDPI |
? |
IE, zoom-relative |
window.screen.logicalXDPI |
? |
IE |
window.screen.logicalYDPI |
? |
IE |
window.screen.systemXDPI |
? |
IE |
window.screen.systemYDPI |
? |
IE |