我想知道是否有方法將sprite圖像縮放到包含div的尺寸 例如,如果我有一個帶有10幀(每個100x100像素,使其爲1000x100)的精靈圖像 而包含div是例如寬度爲200px或50px,有沒有辦法讓框架在div內正確顯示? 背景大小可以嗎? 謝謝CSS sprite scale to div dimensions
0
A
回答
1
您使用的是CSS3嗎?正因爲如此,你可以做以下
(HTML)
<div class='your-box'></div>
(CSS)
.your-box {
background-image: url(.);
background-repeat: no-repeat;
background-size: contain;
}
你可以對其進行測試,在這裏,http://www.w3schools.com/cssref/playit.asp?filename=playcss_background-size&preval=contain(W3學校FTW)
而且我在我的書籤中有這個,http://caniuse.com/background-img-opts這讓我看看哪些瀏覽器適用。
如果你想它爲中心,你反芻添加到CSS
position: absolute;
height: 100%;
width: 100%;
background-position: center;
但正如我所說,這個工程的CSS3和仍然大多數人使用IE8(CSS是由IE9 +支持),但正如我之前所說,看看哪些瀏覽器可以再次與CSS3鏈接編譯(http://caniuse.com/background-img-opts)
相關問題
- 1. HTML Div to CSS?
- 2. Css sprite in div with width%?
- 3. Scale divs height pure CSS
- 4. jQuery Scale DIV
- 5. Scale Numpy array to certain range
- 6. resize css sprite
- 7. css-how to set three parallel DIV?
- 8. CSS forces div to next line
- 9. CSS flex div image to the right
- 10. CSS List Sprite Alignment
- 11. jQuery scale div內容(嵌套div)
- 12. CSS Sprite問題
- 13. align div div to the center of table CSS - PHP
- 14. Jquery UI Scale + CSS的問題
- 15. iphone-How to make a simple sprite?
- 16. div scale轉換問題
- 17. css sprite故障
- 18. CSS Sprite問題
- 19. CSS sprite和IE6
- 20. Responsive css sprite + retina
- 21. css sprite導航
- 22. CSS Sprite + background-size:cover
- 23. css sprite in wordpress
- 24. @Keyframes to scale轉換網站主體
- 25. 顯示選項Scale Display to Real Size
- 26. CSS變換Scale Hover Chrome
- 27. CSS sprite空格下的
- 28. CSS sprite - 圖片不顯示
- 29. css sprite的工具?
- 30. Numpy array dimensions
好友精靈是收集小尺寸圖像合成爲一個縮小http請求。大圖像將導致大的精靈文件大小這將導致您的網站延長加載時間。 – Shail 2013-02-28 09:52:10