css实现加载特效

该博客介绍了如何使用CSS3实现一种独特的加载特效。通过设置8个定位的白色圆圈,并赋予不同的缩放动画时间,营造出只有少数白点旋转的视觉效果。在实际代码中,每个圆圈都有相应的动画和延迟属性,从而在不改变位置的情况下实现动态加载的假象。
摘要由CSDN通过智能技术生成

效果如下:
在这里插入图片描述
在这里插入图片描述
思路:这个效果给人一种只有只有四五个白点在转圈的感觉。,实际上使用的是八个有定位的白色圆圈,设置好每一个的缩放动画时间,在整个加载过程中并没有发生位置的改变。
html:

<body>
		<div class="container">
			<div class="loadiing">
			<div class="container1">
				<div class="circle"></div>
				<div class="circle"></div>
				<div class="circle"></div>
				<div class="circle"></div>
			</div>
			<div class="container2">
				<div class="circle"></div>
				<div class="circle"></div>
				<div class="circle"></div>
				<div class="circle"></div>
			</div>
			</div>
			<p>loadding...</p>
		</div>
	</body>
增加样式和定位后:	

在这里插入图片描述

	<style type="text/css">
	.container{
		width: 100px;
		height: 100px;
		margin: 100px auto;
		background-color: #7f7f7f;
		border-radius: 10px;
	}
	.loadiing{
		width: 40px;
		height: 40px;
		margin: 10px auto;
		position: relative;
	}
	.container1,.container2{
		width: 100%;
		height: 100%;
		position: absolute;
		margin-top: 10px;
	}
	.container2{
		transform: rotate(45deg);
		/* 如果不给container2旋转将与container1位置重叠,旋转使得小圆点分布在八个方向上 */
	}
	.container p{
		text-align: center;
		padding-top: 10px;
		width: 100%;
		color: #fff;
	}
	.circle{
		width: 10px;
		height: 10px;
		background-color: #fff;
		border-radius: 50%;
		position: absolute;/* 给每一个小圆点增加定位 */
		animation: load 1.8s both infinite;
		/* 每一个小圆圈缩放完成的时间为1.8且往复执行动画 */
	}
	.circle:nth-child(1){
		left: 0;
		top: 0;
	}
	
	.circle:nth-child(2){
		right: 0;
		top: 0;
	}
	.circle:nth-child(3){
		right: 0;
		bottom: 0;
	}
	.circle:nth-child(4){
		left: 0;
		bottom: 0;
	}

</style>`

现在给图片加上动画和延时:

		@keyframes load{
   
			0%{
   
				transform: scale
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值