resolution - CSS: Cascading Style Sheets 编辑
The resolution
CSS media feature can be used to test the pixel density of the output device.
Syntax
The 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.
Examples
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;
}
}
Result
Specifications
Specification | Status | Comment |
---|---|---|
Media Queries The definition of 'resolution' in that specification. | Recommendation | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论