纯 css 实现波动效果

449 阅读1分钟
  • 效果展示

动画.gif

  • html
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<link rel="stylesheet" href="./css/index.css">
	</head>
	<body style="background-color: antiquewhite;">
		<div class="toscan">
			<div class="wave">
				<div class="circle">
					<div></div>
				</div>
				<div class="card">
					<img src="./img/scan_btn.png" alt="">
				</div>
			</div>
		</div>
	</body>
</html>
  • css
body{
	box-sizing: border-box;
	margin:0;
	padding:0;
	height: 100%;
	width: 100%;
}
.toscan{
	position:fixed;
	left:50%;
	top:50%;
	transform: translate(-50%,-50%);
	height:100px;
	width:100px;
}
.wave{
	position:relative;
	left:0;
	top:0;
	height:100px;
	width:100px;
}
.circle{
	position: absolute;
	left:0;
	top:0;
	height:100%;
	width:100%;
	border-radius: 50%;
	background-color: #1684FC
}
.circle:first-child {
  animation: circle-opacity 2s infinite;
}
@keyframes circle-opacity {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.6);
  }
}
.card{
	position: absolute;
	left:50%;
	top:50%;
	transform: translate(-50%,-50%);
	height:100px;
	width:100px;
	border-radius: 50%;
	background-color: #1684FC;
	display: flex;
	align-items: center;
	justify-content: center;
}
.card img{
	height:60px;
	width:60px;
}