CSS 加载进度条

这篇文章展示了如何使用CSS来创建两种不同的加载效果:环形加载条和条形加载条,以及一个简单的‘loading’动效。通过CSS的动画关键帧(@keyframes)实现动态视觉反馈,提供用户界面的加载状态指示。
摘要由CSDN通过智能技术生成

CSS 加载进度条

环形加载条

在这里插入图片描述

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>环形加载条</title>
		<style type="text/css">
			.box {
				width: 200px;
				height: 200px;
				border: 1px solid silver;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.circle {
				width: 100px;
				height: 100px;
				border: 10px solid gray;
				border-radius: 50%;
				border-right-color: transparent;
				animation: progress 1s infinite linear;
			}

			@keyframes progress {
				0% {
					transform: rotate(0);
				}

				100% {
					transform: rotate(360deg);
				}
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="circle"></div>
		</div>
	</body>
</html>

条形加载条

在这里插入图片描述

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>条形加载条</title>
		<style type="text/css">
			.box {
				width: 250px;
				height: 100px;
				border: 1px solid silver;
				padding: 10px;
				display: flex;
				align-items: center;
				justify-content: center;
			}

			.progress {
				width: 100%;
				height: 25px;
				border: 1px solid blue;
				border-radius: 25px;
				overflow: hidden;
			}

			.bar {
				width: 100%;
				height: 25px;
				background-image: repeating-linear-gradient(45deg, white 0px, white 20px, blue 20px, blue 40px);
				background-size: 56px 25px;
				animation: move 0.8s linear infinite;
			}

			@keyframes move {
				from {
					background-position: 0 0;
				}

				to {
					background-position: 56px 0;
				}
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div class="progress">
				<div class="bar"></div>
			</div>
		</div>
	</body>
</html>

loading

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>loading</title>
    <style>
      .loading {
        display: flex;
        justify-content: space-around;
        align-items: center;
        width: 80px;
        height: 40px;
        margin: 50px auto;
      }
      .loading span {
        display: inline-block;
        width: 8px;
        height: 40px;
        border-radius: 4px;
        background-color: lightblue;
        animation: loadingAnim 1s ease infinite;
      }
      @keyframes loadingAnim {
        0%,
        100% {
          height: 40px;
        }
        50% {
          height: 20px;
        }
      }
      .loading span:nth-child(2) {
        animation-delay: 0.2s;
      }
      .loading span:nth-child(3) {
        animation-delay: 0.4s;
      }
      .loading span:nth-child(4) {
        animation-delay: 0.6s;
      }
      .loading span:nth-child(5) {
        animation-delay: 0.8s;
      }
    </style>
  </head>
  <body>
    <div class="loading">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>
  </body>
</html>

代码下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值