/**
* contrast滤镜应用在融合元素的父元素(.container)上,且父元素必须设置background。
* blur滤镜应用在融合元素(.circle)上。
* @returns
*/
const demo = () => {
return (
<div className="animation">
<div className="circle circle-1">1</div>
<div className="circle circle-2">2</div>
</div>
)
}
// css
.animation {
background: rgb(255, 254, 254);
width: 100%;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
filter: contrast(30);
.circle {
border-radius: 50%;
filter: blur(20px);
}
.circle-1 {
background: rgb(2, 252, 2);
width: 150px;
height: 150px;
animation: 3s moving linear infinite alternate-reverse;
}
.circle-2 {
background: rgb(2, 253, 2);
width: 200px;
height: 200px;
animation: 3s moving linear infinite alternate;
}
}
@keyframes moving {
//两个元素的移动
0% {
transform: translate(50px);
}
100% {
transform: translate(-50px);
}
}
css融合.gif
网友评论