語法
<resolution> 資料型別由一個嚴格正的<number> 後跟下列單位之一組成。與所有 CSS 尺寸一樣,單位文字和數字之間沒有空格。
單位
dpi-
表示每英寸點數。螢幕通常包含每英寸 72 或 96 個點,但列印文件的 dpi 通常要大得多。由於 1 英寸是 2.54 釐米,因此
1dpi ≈ 0.39dpcm。 dpcm-
表示每釐米點數。由於 1 英寸是 2.54 釐米,因此
1dpcm ≈ 2.54dpi。 dppx-
表示每
px單位的點數。由於 CSSin與 CSSpx之間存在 1:96 的固定比例,1dppx等同於96dpi,這與image-resolution定義的 CSS 中顯示影像的預設解析度相對應。 x-
dppx的別名。
注意: 儘管數字 0 無論單位如何總是相同的,但單位不能省略。換句話說,0 是無效的,不表示 0dpi、0dpcm 或 0dppx。
示例
在媒體查詢中使用
css
@media print and (resolution >= 300dpi) {
/* … */
}
@media (resolution: 120dpcm) {
/* … */
}
@media (resolution >= 2dppx) {
/* … */
}
@media (resolution: 1x) {
/* … */
}
有效解析度
96dpi 50.82dpcm 3dppx
無效解析度
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.
規範
| 規範 |
|---|
| CSS 值和單位模組第 4 級 # resolution |
瀏覽器相容性
載入中…
另見
- resolution 媒體特性
image-resolution屬性- 使用 @media 查詢