我正试图在我正在开发的当前网站上支持各种像素比例。我还想确保提供任何必需的浏览器前缀,以便在合理范围内支持最广泛的各种设备/浏览器。另外,我尽可能使用SVG,但我需要一个用于摄影图像的解决方案。理想情况下,我想提供:@ 2x,@ 3x和@ 4x图像的媒体查询
- @ 1X图像(像素比1.0)
- @ 2倍的图像(的1.25+像素比)
- @ 3倍的图像(的2.25+像素比)
- @ 4倍的图像(的3.25+像素比)
我的问题是什么是去写的媒体查询来实现这一目标的最佳方式是什么?我主要关心的是,我的论点对于我想实现的目标是正确的。我会很感激你的任何建议或建议。目前,我的代码如下:
/* @1x Images (Pixel Ratio 1.0) */
#dgst_shopping_bag {background-image:url(img/shopping_bag.png);}
/* @2x Images (Pixel Ratio of 1.25+) */
@media only screen and (-o-min-device-pixel-ratio: 5/4),
only screen and (-webkit-min-device-pixel-ratio: 1.25),
only screen and (min-device-pixel-ratio: 1.25),
only screen and (min-resolution: 1.25dppx) {
#dgst_shopping_bag {background-image:url(img/[email protected]);}
}
/* @3x Images (Pixel Ratio of 2.25+) */
@media only screen and (-o-min-device-pixel-ratio: 9/4),
only screen and (-webkit-min-device-pixel-ratio: 2.25),
only screen and (min-device-pixel-ratio: 2.25),
only screen and (min-resolution: 2.25dppx) {
#dgst_shopping_bag {background-image:url(img/[email protected]);}
}
/* @4x Images (Pixel Ratio of 3.25+) */
@media only screen and (-o-min-device-pixel-ratio: 13/4),
only screen and (-webkit-min-device-pixel-ratio: 3.25),
only screen and (min-device-pixel-ratio: 3.25),
only screen and (min-resolution: 3.25dppx) {
#dgst_shopping_bag {background-image:url(img/[email protected]);}
}
选择1:我一直在考虑利用<picture>
标签来做到这一点。我知道您可以为不支持<picture>
的浏览器提供替代内容,这是我使用它的主要关注点。你们认为这是提供多像素比例照片的最佳做法吗?
简短的问题:你们的图像上的所有设备都相同的宽度? – 2015-02-26 10:18:09
对于大多数设备,图像尺寸是相同的。我只是换出高像素密度显示器的资产。但是对于较低的断点,由于屏幕尺寸限制,某些图像尺寸较小。 – Mastrianni 2015-02-26 18:49:27