有没有办法使用DPI在css媒体查询而不是px

前端之家收集整理的这篇文章主要介绍了有没有办法使用DPI在css媒体查询而不是px前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_0@
像素宽度和高度不总是讲述整个故事。这对于从屏幕添加删除项目非常有用,但是设置正确的图像不太合适。使用MBP上的视网膜显示器,设置为屏幕一半的浏览器窗口将具有与当今大多数机器相同的宽度像素数。然而,鉴于更高的DPI,显示的图像可能会太小。

有没有办法根据DPI而不是像素的宽度和高度来改变图像?

解决方法

你也可以这么做:
<link
    rel="stylesheet"
    type="text/css"
    href="/css/retina.css"
    media="only screen and (-moz-min-device-pixel-ratio: 2),only screen and (-o-min-device-pixel-ratio: 2/1),only screen and (-webkit-min-device-pixel-ratio: 2),only screen and (min-device-pixel-ratio: 2)"
/>

要么

@media only screen and (-moz-min-device-pixel-ratio: 2),only screen and (min-device-pixel-ratio: 2) {
 /*use CSS to swap out your low res images with high res ones here*/
}
原文链接:https://www.f2er.com/css/218206.html

猜你在找的CSS相关文章