利用HTML,CSS,JS实现动态加载效果

利用HTML,CSS,JS实现动态加载效果

源码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet"  type="text/css" href="loadingstyle.css" />
	</head>
	<script type="text/javascript">
			
			function init(){
				var num = document.getElementById("number");
				var count = 0;
				setInterval(function(){
					if(count<100){
						number.innerText = count+"%";
						count++;
					}
					number.innerText = count+"%";
				},1000);
				
			}
	</script>
	<body onload="init()">
		<div id="frame">
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
			<div class="circle"></div>
		</div>
		<div id="number">0%</div>
	</body>
</html>

*{
	margin: 0;
	padding: 0;
}
body{
	background-color: #001e3c;
}

.circle{
	display: block;
	height: 20px;
	width: 20px;
	border-radius: 100%;
	position: absolute;
	left: 650px;
	top: 300px;
	background-color: #003e7d;
	animation: circleChange 1s ease-in-out infinite;
}
@keyframes circleChange{
	0%{
		background-color: #003e7d;
	}
	20%{
		background-color: #006dda;
	}
	50%,100%{
		background-color: #003e7d;
	}
}
#number{
	width: 100px;
	text-align: center;
	font-size: 20px;
	color: white;
	position: absolute;
	left: 610px;
	top: 354px;
}
.circle:nth-child(1){
	transform: rotate(36deg);
	transform-origin:50% 65px;
	animation-delay: 0;
}
.circle:nth-child(2){
	transform: rotate(72deg);
	transform-origin:50% 65px;
	animation-delay: 0.1s;
}
.circle:nth-child(3){
	transform: rotate(108deg);
	transform-origin:50% 65px;
	animation-delay: 0.2s;
}
.circle:nth-child(4){
	transform: rotate(144deg);
	transform-origin:50% 65px;
	animation-delay: 0.3s;
}
.circle:nth-child(5){
	transform: rotate(180deg);
	transform-origin:50% 65px;
	animation-delay: 0.4s;
}
.circle:nth-child(6){
	transform: rotate(216deg);
	transform-origin:50% 65px;
	animation-delay: 0.5s;
}
.circle:nth-child(7){
	transform: rotate(252deg);
	transform-origin:50% 65px;
	animation-delay: 0.6s;
}
.circle:nth-child(8){
	transform: rotate(288deg);
	transform-origin:50% 65px;
	animation-delay: 0.7s;
}
.circle:nth-child(9){
	transform: rotate(324deg);
	transform-origin:50% 65px;
	animation-delay: 0.8s;
}
.circle:nth-child(10){
	transform: rotate(360deg);
	transform-origin:50% 65px;
	animation-delay: 0.9;
}

运行效果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值