該如何選擇 background-image 和 img 標籤
用img標籤
- 若是你但願別人打印頁面時候包含這張圖片請使用 img 標籤
- 當這張圖片有很是有意義的語義,好比警告圖標,請使用img標籤及它的alt屬性。這樣意味着你能夠向全部的用戶終端現實他的意義。
- IE6下 背景圖片不能益出父級元素 要使用img multiple overlay images in IE6.
- 若是你使用動畫img動畫要比background-image 表現更好improve performance of animations over a background
何時用 CSS background-image
- 若是圖片不是內容的一部分使用 background-image
- 若是使用圖片替換文字請使用 background-image
- 若是你不但願別人打印頁面時候包含這張圖片請使用 background-image
- 若是你想改善加載時間 使用 CSS sprites
- 若是你只想用一張圖片的一部分 請使用 CSS sprites
- 用background-image 以及 background-size:cover 拉伸填充整個窗口
歡迎關注本站公眾號,獲取更多信息