本例演示了filter:blur()
和filter:contrast()
的用法,实现两个盒子融合的效果。
html部分:
<div class="container">
<div class="box1"></div>
<div class="box2"></div>
</div>
css样式:
body{
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 0;
margin: 0;
background: #111;
}
.container{
display: flex;
align-items: center;
justify-content: center;
filter: contrast(50);
background: #111;
width: 600px;
height: 600px;
}
.box1,.box2{
width: 200px;
height: 200px;
border-radius: 50%;
background: #fff;
filter: blur(25px);
}
.box1{
animation: r1 .8s ease-in-out infinite alternate;
}
.box2{
animation: r2 .8s ease-in-out infinite alternate;
}
@keyframes r1{
from{
transform: translateX(142px) rotate(-45deg);
}
to{
transform: translateX(-80px) rotate(45deg);
}
}
@keyframes r2{
from{
transform: translateX(-142px) rotate(45deg);
}
to{
transform: translateX(80px) rotate(-45deg);
}
}