记得前几年手机版淘宝左下角有个狠有意思的圆形按钮,点击后会呈现几个小按钮,并且出场动画很有意思,前面才晓得这种成果叫“粘滞”成果,如图:
那这种成果到底用了什么属性呢?答案是次要用了 filter:blur()
属性,及 filter:contrast()
属性配合
<style>
body{
margin: 0;
padding: 0;
}
.box{
position: relative;
width: 500px;
height: 500px;
filter: contrast(20);
/* 背景色肯定要为实底色,否则两个元素边缘会有含糊成果 */
background-color: #fff;
}
.circle-big{
position: absolute;
top: 20px;
left: 100px;
width: 100px;
height: 100px;
border-radius: 50%;
filter: blur(6px);
box-sizing: border-box;
animation: toRight 3s ease-out infinite;
background-color: #333;
}
.circle-small{
position: absolute;
top: 35px;
left: 220px;
width: 60px;
height: 60px;
border-radius: 50%;
filter: blur(6px);
box-sizing: border-box;
animation: toLeft 3s ease-out infinite;
background-color: #FFFC00;
}
@keyframes toRight{
50%{left: 150px;}
}
@keyframes toLeft{
50%{left: 150px;}
}
</style>
<div class="box">
<div class="circle-big"></div>
<div class="circle-small"></div>
</div>
最终成果如图: