css3-雪花飘落效果
2021年06月17日
567
css3-雪花飘落效果

html:
<section class="sn"> <span class="snow snow-one"></span> <span class="snow snow-two"></span> <span class="snow snow-three"></span> </section>
css:
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
html,body{
width: 100%;
height: 100%;
}
body{
background-image: url('./img/sbg1.jpeg');
background-size: 100% 100%;
background-repeat: no-repeat;
overflow: hidden;
}
.sn{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
.sn .snow{
width: 100%;
height: 100%;
background-image: url('./img/snow.png');
background-position: 0 0;
background-size: cover;
position: absolute;
left: 0;
top: 0;
}
.sn .snow-one{
filter: blur(4px);
animation: animateOne 15s linear infinite;
}
.sn .snow-two{
filter: blur(3px);
animation: animateTwo 15s linear infinite;
background-size: 800px;
}
.sn .snow-three{
filter: blur(1px);
animation: animateThree 15s linear infinite;
background-size: 300px;
}
@keyframes animateOne {
0%{
background-position: 0 0;
}
100%{
background-position: 150px 100vh;
}
}
@keyframes animateTwo {
0%{
background-position: 0 0;
}
100%{
background-position: 300px 800px;
}
}
@keyframes animateThree {
0%{
background-position: 0 0;
}
100%{
background-position: 0 100vh;
}
}
</style>
