龙空技术网

CSS电池充电特效源代码

田了个田 112

前言:

此刻咱们对“css电池动画”都比较着重,朋友们都需要学习一些“css电池动画”的相关资讯。那么小编也在网摘上搜集了一些关于“css电池动画””的相关资讯,希望各位老铁们能喜欢,朋友们一起来学习一下吧!

<!-- 今天我们将使用CSS来实现电池充电动画效果,现在就开始吧! --><!DOCTYPE html><html lang="en"><head>	<meta charset="UTF-8">	<meta name="viewport" content="width=device-width, initial-scale=1.0">	<title>CSS 电池充电效果 - 田了个田田</title>	<!-- 开始添加样式 -->	<style>		*{			padding:0;			marging:0;			box-sizing: border-box;		}		body {			display: flex;			align-items: center;			justify-content: center;			background:#e7e7e7;			min-height: 100vh;		}		.battery {			width: 360px;			height: 180px;			border: 1px solid #000;			border-top-right-radius: 11px;			border-bottom-right-radius: 11px;			position: relative;		}		.battery:before {			content:"";			position: absolute;			width: 10px;			height: 36px;			background:#000;			top: 50%;			right: -16px;			transform:translate(-50%,-50%);			border-top-right-radius: 5px;			border-bottom-right-radius: 5px;		}		/*到此为止,电池的轮廓已经画出来了,接下来需要添加一个充电的动画效果*/		.wrap {			height: 100%;			background:green;			animation: charging 3s ease infinite;			border-top-right-radius: 10px;			border-bottom-right-radius: 10px;		}		@keyframes charging {			0%{width: 0;}			100%{width: 100%;}					}	</style></head><body>	<!-- html部分,代码就这么简单! -->	<div class="battery">		<div class="wrap"></div>	</div></body></html>

制作该效果需要基本的html和css知识。点击观看该教程的头条视频。

标签: #css电池动画