2 回答

TA貢獻1812條經驗 獲得超5個贊
首先加載所有它們,否則即使圖像尺寸很小,您也需要等待關鍵幀內的加載。然后,您可以設置背景大小的動畫以一次顯示一個
body {
animation: div 5s infinite;
height: 100vh;
margin: 0;
background-image:
url(https://i.picsum.photos/id/110/800/800.jpg),
url(https://i.picsum.photos/id/151/800/800.jpg),
url(https://i.picsum.photos/id/127/800/800.jpg),
url(https://i.picsum.photos/id/251/800/800.jpg),
url(https://i.picsum.photos/id/126/800/800.jpg);
background-position: center;
background-size: cover;
background-repeat: no-repeat;
}
html {
background: rgba(255, 255, 255, 0.53);
}
@keyframes div {
20% {
background-size: cover,0 0,0 0,0 0,0 0;
}
40% {
background-size: 0 0,cover,0 0,0 0,0 0;
}
60% {
background-size: 0 0,0 0,cover,0 0,0 0;
}
80% {
background-size: 0 0,0 0,0 0,cover,0 0;
}
100% {
background-size: 0 0,0 0,0 0,0 0,cover;
}
}

TA貢獻1829條經驗 獲得超7個贊
為您想要使用的任何關鍵幀創建一個臨時 div,并在頁面加載時在后臺啟動動畫。像這樣的東西:
.temp-hidden-div {
animation: div 1 100ms;
/*it's better to put a smaller duration here since this animation must run for the
shortest amount of time possible*/
}
- 2 回答
- 0 關注
- 142 瀏覽
添加回答
舉報