好了,所以基本上我用GIF作爲背景圖像,但我想它顯示靜態圖像,直到GIF完全加載並準備播放。gif加載後更改背景圖片?
看了一些類似的主題,我知道你可以針對與JS元素和改變他們,一旦他們加載但是我已經看到了目標的img標籤的唯一實例,而不是通過CSS的背景圖像。
繼承人的一個片段,如果它有助於
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
width: 100%;
height: 100%;
background: #232228 url(../img/bg-center.jpg) top no-repeat; /* Static */
background: #232228 url(../img/bg-center.gif) top no-repeat; /* Animated */
}
試試這個http://stackoverflow.com/questions/29742508/show-loading-gif-while-image-is-loading –
林不使用圖像標籤雖然,香港專業教育學院看到關於它的幾個帖子用圖像標籤,但找不到任何東西特別僅指定背景圖像 –
您應該使用常規圖像,以便您可以使用onload事件。沒有DOM事件用於背景圖像。 – PHPglue