用animation的属性制作加载圆

代码如下:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>进度</title>
	<style>
		.box{
			width: 200px;
			height: 200px;
			border: solid 2px #ccc;
			border-radius: 50%;
			margin: 60px auto;
			position: relative;
		}
		.box:after{
			content: "";
			position: absolute;
			width: 100%;
			height: 100%;
			border-radius: 50%;
			top:-2px;
			left: -2px;
			border: solid 2px;
			border-color: #333 transparent transparent transparent;
			animation: loading 2s linear infinite;
		}
		.box:before{
			content:attr(hov);
			position: absolute;
			width: 100%;
			height: 100%;
			top: 0;
			left: 0;
			text-align: center;
			line-height: 200px;
		}
		@keyframes loading{
			0%{
				transform: rotate(0deg);
			}
			100%{
				transform: rotate(360deg);
			}
		}
	</style>
</head>
<body>
	<div class="box" hov="loading..."></div>
</body>
</html>

运行结果截图如下图所示:

 

猜你喜欢

转载自blog.csdn.net/zhangqling/article/details/81807929