CSS實現漂亮的小水球效果

星空天宇發表於2020-05-24

先看效果圖:
在這裡插入圖片描述
程式碼:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>小水球</title>
		<style>
			*{
				margin:0;
				padding: 0;
			}
			body{
				height: 100vh;
				background: linear-gradient(rgb(95,95,250) 10%,rgb(3,3,110));
			}
			
			.main,.wave{
				width:200px;
				height:200px;
				border-radius: 50%;
				position: absolute;
				left: 50%;
				top:50%;
				transform: translate(-50%,-50%);
			}
			.main{
				border:3px solid darkturquoise;
				padding: 10px;
			}
			.wave{
				background: darkturquoise;
				overflow: hidden;
			}
			.wave::before{
				content: "水球";
				position: absolute;
				left: 50%;
				top: 0px;
				color: darkturquoise;
				z-index: 99;
				transform: translate(-50%,30px);
				text-transform: uppercase;
			}
			.wave::after{
				content: "";
				width: 300px;
				height: 300px;
				background: rgba(255,255,255,0.8);
				position: absolute;
				left: 50%;
				top: 0;
				transform: translate(-50%,-60%);
				border-radius: 40%;
				animation: wave 5s linear infinite;
			}
			
			@keyframes wave{
				100%{
					transform: translate(-50%,-60%) rotate(360deg);
				}
			}
		</style>
	</head>
	<body>
		<div class="main">
			<div class="wave"></div>
		</div>
	</body>
</html>

參考視訊:https://www.bilibili.com/video/BV1nV411d7Q2

相關文章