-webkit-device-pixel-ratio
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2018.
非标准: 该特性尚未标准化。我们不建议在生产环境中使用非标准特性,因为它们在浏览器中的支持有限,且可能发生变化或被移除。不过,在没有标准选项的特定情况下,它们可以作为合适的替代方案。
-webkit-device-pixel-ratio
是一个非标准的布尔类型 CSS 媒体类型,是标准 resolution
媒体类型的一个替代方案。
Its value is the number of device pixels used to represent each CSS px
. Although the value is a <number>
and thus doesn't syntactically allow units, its implicit unit is dppx
.
Syntax
-webkit-device-pixel-ratio
is a range value meaning the prefixed -webkit-min-device-pixel-ratio
and -webkit-max-device-pixel-ratio
are also available.
@media (-webkit-min-device-pixel-ratio: 2) { ... }
/* is equivalent to */
@media (min-resolution: 2dppx) { ... }
/* And likewise */
@media (-webkit-max-device-pixel-ratio: 2) { ... }
/* is equivalent to */
@media (max-resolution: 2dppx) { ... }
Specifications
Specification |
---|
Compatibility # css-media-queries-webkit-device-pixel-ratio |