/* A unit of "dppx" is implied: */
@media (-webkit-min-device-pixel-ratio: 2) {
/* … */
}
/* It is equivalent to: */
@media (min-resolution: 2dppx) {
/* … */
}
/* Similarly: */
@media (-webkit-max-device-pixel-ratio: 2) {
/* … */
}
/* It is equivalent to: */
@media (max-resolution: 2dppx) {
/* … */
}`-webkit-device-pixel-ratio` CSS media feature
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
<p>This is a test of your device's pixel density.</p>/* Exact resolution */
@media (-webkit-device-pixel-ratio: 1) {
p {
color: red;
}
}
/* Minimum resolution */
@media (-webkit-min-device-pixel-ratio: 1.1) {
p {
font-size: 1.5em;
}
}
/* Maximum resolution */
@media (-webkit-max-device-pixel-ratio: 3) {
p {
background: yellow;
}
}