CSS实现两个元素相融效果(粘滞效果)
网站建设 2023-01-28 21:39www.1681989.com免费网站
记得前几年手机版淘宝左下角有个狠有意思的圆形按钮,点击后会出现几个小按钮,并且出场动画很有意思,后面才知道这种效果叫“粘滞”效果,如图
那这种效果到底用了什么属性呢?答案是主要用了filter:blur()属性,及filter:contrast()属性配合
<style>
body{
marg: 0;
paddg: 0;
}
.box{
position: relative;
width: 500px;
height: 500px;
filter: contrast(20);
/ 背景色一定要为实底色,否则两个元素边缘会有模糊效果 /
background-color: #fff;
}
.circle-big{
position: absolute;
: 20px;
left: 100px;
width: 100px;
height: 100px;
border-radius: 50%;
filter: blur(6px);
box-sizg: border-box;
animation: toRight 3s ease-out fite;
background-color: #333;
}
.circle-small{
position: absolute;
: 35px;
left: 220px;
width: 60px;
height: 60px;
border-radius: 50%;
filter: blur(6px);
box-sizg: border-box;
animation: toLeft 3s ease-out fite;
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>
最终效果如图
到此这篇关于CSS实现两个元素相融效果(粘滞效果)的文章就介绍到这了,更多相关CSS两个元素相融内容请搜索狼蚁SEO以前的文章或继续浏览狼蚁网站SEO优化的相关文章,希望大家以后多多支持狼蚁SEO!