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 关注
- 106 浏览
添加回答
举报