CSS实现loading图标

本文介绍了一种使用CSS实现的动态加载效果,通过定位和动画控制,创建了八个同步但时间错位的绿色圆点,形成了独特的加载动画。文章详细解释了如何通过定位、旋转和动画延迟来实现这一效果。
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>loading</title>
	<style>
	    *{
	    	margin: 0;padding: 0;
	    }
		.contont {
			height: 40px;width: 40px;
			top: 50%;left: 50%;
			position: absolute;
		}
		.contont p{
			height: 10px;
			width: 10px;
			border-radius: 5px;
			background: green;
			animation:mymove 1.5s infinite linear;
			position: absolute;
		}
		.contont .p1{
			top: 0;
			left: 0;
		}
		.contont .p2{
			top: 0;
			right: 0;
		}
		.contont .p3{
			right: 0;
			bottom: 0;
		}
		.contont .p4{
			left: 0;
			bottom: 0;
		}
		.contont:nth-child(2){
			transform: rotate(45deg);
		}
		@keyframes mymove{
			0% {
				transform: scale(0)
			}
			50% {
				transform: scale(1)
			}
			100% {
				transform: scale(0)
			}
		}
		.contont:nth-child(1) p:nth-child(1){
			animation-delay: -1.5s;
		}
		.contont:nth-child(2) p:nth-child(1){
			animation-delay: -1.3s;
		}
		.contont:nth-child(1) p:nth-child(2){
			animation-delay: -1.1s;
		}
		.contont:nth-child(2) p:nth-child(2){
			animation-delay: -0.9s;
		}
		.contont:nth-child(1) p:nth-child(3){
			animation-delay: -0.7s;
		}
		.contont:nth-child(2) p:nth-child(3){
			animation-delay: -0.5s;
		}
		.contont:nth-child(1) p:nth-child(4){
			animation-delay: -0.3s;
		}
		.contont:nth-child(2) p:nth-child(4){
			animation-delay: -0.1s;
		}
	</style>
</head>
<body>
	<div class="contont">
		<p class="p1"></p>
		<p class="p2"></p>
		<p class="p3"></p>
		<p class="p4"></p>
	</div>
	<div class="contont">
		<p class="p1"></p>
		<p class="p2"></p>
		<p class="p3"></p>
		<p class="p4"></p>
	</div>
</body>
</html>

思路:

在div中创建4个yua圆点,进行定位,然后再复制一份,进行45度旋转实现了八个点

进行animation动画,由于时间不同步,设置每个圆点的延迟时间,而负数就能实现了

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值