手写一个炫酷的loading效果

效果图:

代码如下:

<div class="wrapper">
	<div class="circle-body">
		<div class="circle"></div>
		<div class="circle"></div>
		<div class="circle"></div>
	</div>
	<div class="circle-loading">
		Loading
		<span class="loading__dot">.</span>
		<span class="loading__dot">.</span>
		<span class="loading__dot">.</span>
	</div>
</div>

 

*{margin: 0; padding: 0;}
.wrapper {
    color: #fff;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    width: 100vw;
    height: 100vh;
	position: relative;
    background-color: black;
    display: flex;
    justify-content: center;
    align-items: center;
	.circle-body {
		height: 500px;
		width: 500px;
		padding: 3px;
		position: relative;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: row;
		overflow: hidden;
		box-sizing: border-box;
		.circle {
			position: absolute;
			display: block;
			border-radius: 50%;
			border: 10px solid #fffc00;
			&:nth-child(1) {
				height: 350px;
				width: 350px;
				animation: animate1 1.5s infinite linear, borderColor 1.5s 0.2s infinite linear;
				border-width: 10px;
				opacity: 0.9;
			}
			&:nth-child(2) {
				height: calc(350px * 0.65);
				width: calc(350px * 0.65);
				animation: animate2 1.5s infinite linear, borderColor 1.5s 1s infinite linear;
				border-width: 8px;
				opacity: 0.7;
			}
			&:nth-child(3) {
				height: calc(350px * 0.45);
				width: calc(350px * 0.45);
				animation: animate3 1.5s infinite linear, borderColor 1.5s 1.5s infinite linear;
				border-width: 6px;
				opacity: 0.5;
			}
		}
	}

	.circle-loading {
		box-sizing: border-box;
		position: absolute;
		font-size: 26px;
		color: #fffc00;

		.loading__dot {
			animation: 1s loading infinite;
		}
		.loading__dot:nth-child(2) {
			animation-delay: 250ms;
		}
		.loading__dot:nth-child(3) {
			animation-delay: 500ms;
		}
	}
}

@keyframes borderColor {
	0% {
		border-color: #fffc00;
	}
	15% {
		border-color: #0fb34e;
	}
	30% {
		border-color: #0b669b;
	}
	45% {
		border-color: #4c0983;
	}
	60% {
		border-color: #a30c8f;
	}
	75% {
		border-color: #a30c39;
	}
	100% {
		border-color: #fffc00;
	}
}

@keyframes animate1 {
	0% {
		transform: rotateZ(20deg) rotateY(0deg);
	}
	100% {
		transform: rotateZ(100deg) rotateY(360deg);
	}
}
@keyframes animate2 {
	0% {
		transform: rotateZ(100deg) rotateX(0deg);
	}
	100% {
		transform: rotateZ(0deg) rotateX(360deg);
	}
}
@keyframes animate3 {
	0% {
		transform: rotateZ(100deg) rotateX(-360deg);
	}
	100% {
		transform: rotateZ(-360deg) rotateX(360deg);
	}
}

@keyframes loading {
	50% {
		color: transparent;
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

inticaler

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值