我正在設計一個具有響應式設計的CSS3/HTML5應用程序。響應式設計中的背景位置和寬度百分比的小精靈
對於性能,我使用精靈而不是普通圖像。所以,我使用background-image
和background-position
。在整個應用中,縱橫比保持不變。
在像素寬度爲background-position
且百分比爲background-position
時,圖像顯示效果很好。但在百分比和background-position
的寬度中,圖像有時看起來很糟糕(當精靈有兩個以上的圖像時)。
精靈大小102px x 918 px;
精靈尺寸爲102px x 102px;
十字紅色是9張圖像中精靈中的最後一張圖像。
見壞背景位置:
這是相同的,但與637px顯示不錯:
任何人都知道如何使用CSS3解決?
更新: 我的問題是在寬度和背景位置的百分比。
background-position: 0 100%; // Show the second image in the sprite.
background-position: 0 700%; // Show image 8 in the sprite but sometimes, in some width, the image showed is the image 8 and a little image 7.
測試,我不理解你。我使用百分比。我的問題是在寬度和背景位置的百分比。 '背景位置:0 100%; //在精靈中顯示第二個圖像。背景位置:0 700%; //在精靈中顯示圖像8,但有時在某些寬度下,圖像顯示的是圖像8和一個小圖像7.「你知道我是如何修復它的嗎?謝謝! P.D:請在我的文章中看到圖片。 –