我正試圖在我正在開發的當前網站上支持各種像素比例。我還想確保提供任何必需的瀏覽器前綴,以便在合理範圍內支持最廣泛的各種設備/瀏覽器。另外,我儘可能使用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