resolution CSS media feature can be used to test the pixel density of the output device.

句法

resolution feature is specified as a <resolution> value representing the pixel density of the output device. It is a range feature, meaning that you can also use the prefixed min-resolution and max-resolution variants to query minimum and maximum values, respectively.

范例

HTML

<p>This is a test of your device's pixel density.</p>
					

CSS

/* Exact resolution */
@media (resolution: 150dpi) {
  p {
    color: red;
  }
}
/* Minimum resolution */
@media (min-resolution: 72dpi) {
  p {
    text-decoration: underline;
  }
}
/* Maximum resolution */
@media (max-resolution: 300dpi) {
  p {
    background: yellow;
  }
}
					

结果

规范

规范 状态 注释
Media Queries
The definition of 'resolution' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
resolution media feature Chrome 完整支持 29 Edge 完整支持 12 Firefox 完整支持 8
完整支持 8
部分支持 3.5 注意事项
注意事项 Supports <integer> values only.
IE 完整支持 9 Opera 完整支持 16
完整支持 16
不支持 10 — 15
Safari 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 78087 .
WebView Android 完整支持 ≤37 Chrome Android 完整支持 29 Firefox Android 完整支持 8
完整支持 8
部分支持 4 注意事项
注意事项 Supports <integer> values only.
Opera Android 完整支持 16
完整支持 16
不支持 10.1 — 14
Safari iOS 不支持 No 注意事项
不支持 No 注意事项
注意事项 bug 78087 .
Samsung Internet Android 完整支持 2.0

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

见实现注意事项。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Conditional Rules
  4. Media Queries
  5. 指南
    1. Using feature queries
    2. Testing media queries programmatically
    3. Using Media Queries for Accessibility
    4. Using media queries
  6. At-Rules
    1. @document
    2. @import
    3. @media
    4. @supports

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1