css特效之水滴效果

css特效之水滴效果

想看看效果:

在这里插入图片描述

html代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="index.css"/>
	</head>
	<body>
		<div class="container">
			<div class="drop"></div>
			<div class="drop"></div>
			<div class="drop"></div>
			<div class="collection"></div>
			<span>80%</span>
		</div>
	</body>
</html>

css代码:

body{
    
    
	margin: 0;
}

.container{
    
    
	display: flex;
	justify-content: center;
	align-items: center;
	min-height: 100vh;
	background-color: #000000;
	flex-direction: column;
	filter:contrast(30)
	/* filter CSS属性将模糊或颜色偏移等图形效果应用于元素。
	滤镜通常用于调整图像,背景和边框的渲染 */
}

.drop{
    
    
	position: absolute;
	width: 100px;
	height: 100px;
	background: #FFFFFF;
	border-radius: 50%;
	filter: blur(20px);
	opacity: 0;
	animation: 3s drop linear infinite;
}

.drop:nth-child(2){
    
    
	animation-delay: .5s;
}
.drop:nth-child(3){
    
    
	animation-delay: .7s;
}

.collection{
    
    
	width: 100px;
	height: 100px;
	background-color: #fff;
	border-radius: 50%;
	filter: blur(20px);
	animation: 3s collection linear infinite;
	animation-delay: 2s;
}
span{
    
    
	
	position: absolute;
	font-family: helvetica;
	font-size: 30px;
}
@keyframes collection{
    
    
	0%{
    
    
		transform: scale(1) rotate(0deg);
	}50%{
    
    
		transform: scale(1.3) rotate(180deg);
		width: 90px;
		border-top-left-radius: 40%;
		border-bottom-left-radius: 45%;
	}100%{
    
    
		transform: scale(1) rotate(360deg);
	}
}
@keyframes drop{
    
    
	0%{
    
    
		transform: scale(.7) translateY(-600%);
		opacity: 0;
	}
	50%{
    
    
		transform: scale(.4) translateY(-80%);
		opacity: 1;
	}
	100%{
    
    
		
		transform: scale(.3) translateY(0px);
		
	}
}

总结:

​ 改代码主要使用了css3中的filter滤镜 filter - CSS(层叠样式表) filter CSS属性将模糊或颜色偏移等图形效果应用于元素。滤镜通常用于调整图像,背景和边框的渲染。

blur():

blur() 函数将高斯模糊应用于输入图像。radius 定义了高斯函数的标准偏差值,或者屏幕上有多少像素相互融合,因此,较大的值将产生更多的模糊。若没有设置值,默认为0。该参数可以指定为 CSS 长度,但不接受百分比值。例子:filter: blur(5px)

contrast()

contrast() 函数可调整输入图像的对比度。值是 0% 的话,图像会全黑。值是 100%,图像不变。值可以超过 100%,意味着会运用更低的对比。若没有设置值,默认是 1。例子:filter: contrast(200%)

使用这两个函数让整个大的div的显示边缘有了更为有流体的效果,在通过animation的动态效果,逐步放大,显示和隐藏,旋转,延迟动画的效果达到该动态效果。

猜你喜欢

转载自blog.csdn.net/qq_46063425/article/details/119772833