<resolution>

分辨率:用于描述媒体查询中的分辨率的<resolution> CSS数据类型表示输出设备的像素密度。

在屏幕上,单位与CSS英寸,厘米或像素有关,而与物理值无关。

Syntax

<resolution>数据类型由严格为正<number>组成,后跟下面列出的单位之一。与所有CSS维度一样,单位字面值与数字之间没有空格。

单位

dpi
表示每英寸的点数。屏幕通常每英寸包含72或96个点,但打印文档的dpi通常要大得多。 1英寸是2.54厘米,1dpi≈0.39dpcm。
dpcm
每厘米上的点数。1英寸是2.54厘米, 1dpcm ≈ 2.54dpi.
dppx
表示每个px的点数。 由于CSS px的固定比率为1:96,因此1dppx相当于96dpi。 which corresponds to the default resolution of images displayed in CSS as defined by image-resolution.
x
 dppx 的别名

Note: Although the number 0 is always the same regardless of unit, the unit may not be omitted. In other words, 0 is invalid and does not represent 0dpi, 0dpcm, or 0dppx.

Examples

Use in a media query

@media print and (min-resolution: 300dpi) { ... }

Valid resolutions

96dpi
50.82dpcm
3dppx

Invalid resolutions

72 dpi     Spaces are not allowed between the number and the unit.
ten dpi    The number must use digits only.
0          The unit is required.

Specifications

Specification Status Comment
CSS Values and Units Module Level 4
<resolution>
Editor's Draft Adds the x unit.
CSS Values and Units Module Level 3
<resolution>
Candidate Recommendation Adds the dppx unit.
Media Queries
<resolution>
Recommendation Initial definition.

Browser compatibility

BCD tables only load in the browser

See also