还在好奇充电时那个充电效果是怎么出来的吗?

才学完html和css,那就给你们写个充电效果(需要的自取哈,就麻烦动动你们的小手点个赞呗🙂)

HTML部分

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>电池充电</title>
	<link rel="stylesheet" type="text/css" href="3.css">
</head>
<body>
	<div class="box">
		<div class="battery">
			<div class="cover"></div>
		</div>
		<div class="number">95.2%</div>
		<div class="contrast">
			<span class="bubble"></span>
			<span class="bubble"></span>
            <span class="bubble"></span>
			<span class="bubble"></span>			
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble"></span>
			<span class="bubble-home"></span>
			<div class="circle"></div>
		</div>
	</div>
</body>
</html>

CSS部分

.box{
	width: 800px;
	height: 800px;
	background: black;
	margin: 0 auto;
	position: relative;
	padding-top: 20px;
}
.battery{
	width: 200px;
	height: 320px;
	background: #fff;
	margin-left: 20px;
	margin-top:20px;
	border-radius: 15px 15px 5px 5px;
	position: relative;
}
.battery::before{
       content: "";
       width: 50px;
       height: 20px;
       background: #fff;
       position: absolute;
       top: -20px;
       left: 50%;
       margin-left:-25px;
}
.battery::after{
	content: "";
	position: absolute;
	left:0;
	right: 0;
	/* top: 90%; */
	bottom: 0;
	text-outline:90%;
	background: linear-gradient(to bottom,#7abcff 0%,#00BCD4 44%,#2196F3 100%);
    animation:charge 10s linear infinite;
}
@keyframes charge{
	0%{
            top:100%;
	
	
       filter:hue-rotate(90deg);
	}
	95%{
		top: 5%;
		border-radius: 0px;
	}
	100%{
		top: 0%;
		filter:hue-rotate(0deg);
		border-radius: 15px 15px 0 0;
	}
}
.cover{
	width: 100%;
	height: 100%;
	border-radius:15px 15px 5px 5px;
	position: absolute;
	top:0;
	left:0;
	z-index: 1;
	overflow: hidden;
}
.cover::before{
	content: "";
	width: 400px;
	height: 400px;
	background: rgba(255,255,255,0.8);
	position: absolute;
	border-radius: 40% 30%;
	left: -50%;
	animation:coverBefore 10s linear infinite;
}
.cover::after{
	content: "";
	width: 400px;
	height: 400px;
	background: rgba(255,255,255,0.7);
	position: absolute;
	border-radius: 42% 40%;
	left: -50%;
	animation:coverAfter 10s linear infinite;
}
@keyframes coverBefore{
	0%{
		transform:rotate(0deg);
		bottom: 0%;
	}
	100%{
		transform:rotate(360deg);
		bottom: 100%;
	}
}
@keyframes coverAfter{
	0%{
		transform:rotate(30deg);
		bottom: 2%;
	}
	100%{
		transform:rotate(360deg);
		bottom: 95%;
	}
}
.contrast{
	width: 70%;
	height: 70%;
	/* background: lightblue; */
	background: black;
	/*position: relative;*/
	position: absolute;
	top: 20px;
	left: 30%;
	filter:contrast(15);
	animation:hueRotate 5s linear infinite;
}
@keyframes hueRotate{
	0%{
		filter:contrast(15) hue-rotate(0);
	}
	100%{
		filter:contrast(15) hue-rotate(360deg);
	}
}
.circle{
	width: 300px;
	height: 300px;
	/*background: lightblue;*/
	position: absolute;
	left: 50%;
	top: 0;
	margin-left: -150px;
	filter:blur(8px);
	animation:circleRotate 5s linear infinite;

}
.circle::before{
	content: "";
	width: 200px;
	height: 200px;
	/*background: lightblue;*/
	background: #00ff6f;
	position: absolute;
	top: 50%;
	left: 50%;
	transform:translate(-50%,-50%);
	border-radius: 42% 38% 62% 49% / 45%;
}
.circle::after{
	content: "";
	width: 176px;
	height: 178px;
	/*background: lightblue;*/
	background: black;
	position: absolute;
	top: 50%;
	left: 50%;
	transform:translate(-50%,-50%);
	border-radius:50%;
}
@keyframes circleRotate{
	0%{
		transform:rotate(0deg);
	}
	100%{
		transform:rotate(360deg);
	}
}
.number{
	width: 200px;
	height: 200px;
	text-align: center;
	line-height: 200px;
	color: #fff;
	position: absolute;
	top: 10%;
	left: 65%;
	margin-left: -100px;
	z-index: 1;
	font-size: 30px;
}
.bubble-home{
	width: 150px;
	height: 50px;
	background: #00ff6f;
	position: absolute;
	bottom: 0;
        left:50%;
	margin-left: -75px;
	
	border-radius: 150px 150px 0 0;
	filter:blur(8px);
}
.bubble{
	/* width: 20px;
	height: 20px; */
        /*background:red;*/
	background: #00ff6f;
	border-radius: 100%;
	position: absolute;
	left: 50%;
	bottom: 0;
	transform:translate(-50%,0);
	z-index: 100;
	filter:blur(5px);
	animation:bubbleMoveUp 5s ease-in-out infinite;
}
.bubble:nth-child(1){
    width: 20px;
	height: 20px;
	left: 50%;
	animation-duration:5s;
	animation-delay:1s;

}
.bubble:nth-child(2){
    width: 22px;
	height: 22px;
	left: 50%;
	animation-duration:4s;
	animation-delay:1.2s;

}
.bubble:nth-child(3){
    width: 24px;
	height: 24px;
	left: 42%;
	animation-duration:1.8s;
	animation-delay:1.2s;

}
.bubble:nth-child(4){
    width: 22px;
	height: 22px;
	left: 45%;
	animation-duration:3.5s;
	animation-delay:1.6s;

}
.bubble:nth-child(5){
    width: 24px;
	height: 24px;
	left: 48%;
	animation-duration:4.2s;
	animation-delay:1.8s;

}
.bubble:nth-child(6){
    width: 18px;
	height: 20px;
	left: 49%;
	animation-duration:5.2s;
	animation-delay:1.4s;

}
.bubble:nth-child(7){
    width: 26px;
	height: 24px;
	left: 43%;
	animation-duration:4.8s;
	animation-delay:1.7s;

}
.bubble:nth-child(8){
    width: 22px;
	height: 22px;
	left: 52%;
	animation-duration:3.5s;
	animation-delay:1.4s;

}
.bubble:nth-child(9){
    width: 20px;
	height: 20px;
	left: 46%;
	animation-duration:3.0s;
	animation-delay:1.5s;

}
.bubble:nth-child(10){
    width: 20px;
	height: 20px;
	left: 53%;
	animation-duration:4.2s;
	animation-delay:2.0s;

}
.bubble:nth-child(11){
    width: 26px;
	height: 20px;
	left: 42%;
	animation-duration:4.6s;
	animation-delay:1.2s;

}
.bubble:nth-child(12){
    width: 24px;
	height: 24px;
	left: 50%;
	animation-duration:5.0s;
	animation-delay:3.5s;

}
.bubble:nth-child(13){
    width: 22px;
	height: 22px;
	left: 50%;
	animation-duration:4.2s;
	animation-delay:4.0s;

}
.bubble:nth-child(14){
    width: 24px;
	height: 24px;
	left: 42%;
	animation-duration:3.5s;
	animation-delay:3.6s;

}
.bubble:nth-child(15){
    width: 20px;
	height: 20px;
	left: 45%;
	animation-duration:5.2s;
	animation-delay:3.7s;

}
.bubble:nth-child(16){
    width: 22px;
	height: 22px;
	left: 49%;
	animation-duration:5.2s;
	animation-delay:1s;

}
.bubble:nth-child(17){
    width: 22px;
	height: 20px;
	left: 55%;
	animation-duration:4.5s;
	animation-delay:3.8s;

}
@keyframes bubbleMoveUp{
	0%{
		bottom: 0;
	}
	100%{
		bottom: calc(100% - 260px);
	}
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值