当前位置: 首页 > article >正文

【css酷炫效果】纯CSS实现进度条加载动画

【css酷炫效果】纯CSS实现进度条加载动画

  • 创作背景
  • html结构
  • css样式
  • 完整代码
    • 基础版
    • 进阶版
  • 效果图

通过CSS渐变与背景位移动画,无需JavaScript即可创建流体动态进度条
想直接拿走的老板,链接放在这里:https://download.csdn.net/download/u011561335/90490485

创作随缘,不定时更新。

创作背景

刚看到csdn出活动了,赶时间,直接上代码。

html结构

<div class="progress-bar">
    <div class="progress"></div>
</div>

css样式

.progress-bar {
    width: 300px;
    height: 20px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
}

.progress {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        #3498db 25%, 
        #9b59b6 50%, 
        #e74c3c 75%);
    background-size: 200% 100%;
    animation: flow 2s linear infinite;
    transform-origin: left;
    /* transform: scaleX(0.7); 设置当前进度70% */
}

@keyframes flow {
    0% { background-position: 100% 0; }
    100% { background-position: 0% 0; }
}

完整代码

基础版

<!DOCTYPE html>
<html>
<head>
<style>
.progress-bar {
    width: 300px;
    height: 20px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
}

.progress {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        #3498db 25%, 
        #9b59b6 50%, 
        #e74c3c 75%);
    background-size: 200% 400%;
    animation: flow 2s linear infinite;
    transform-origin: left;
}

@keyframes flow {
    0% { background-position: 100% 0; }
    100% { background-position: 0% 0; }
}
</style>
</head>
<body>
    <div style='text-align:center;margin-top:50px;'>
		<div class="progress-bar">
			<div class="progress"></div>
		</div>
	</div>
	
</body>
</html>

进阶版

<!DOCTYPE html>
<html>
<head>
<style>
.progress-bar {
    width: 300px;
    height: 20px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
}

.progress {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        #3498db 25%, 
        #9b59b6 50%, 
        #e74c3c 75%);
    background-size: 200% 400%;
    animation: flow 2s linear infinite;
    transform-origin: left;
	
	
    background: repeating-linear-gradient(
        -45deg,
        #3498db,
        #3498db 10px,
        #2980b9 10px,
        #2980b9 20px
    );
    background-size: 200% 100%;
	
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
    border-right: 3px solid rgba(255,255,255,0.3);
    transition: transform 0.3s ease-out;
}

@keyframes flow {
    0% { background-position: 100% 0; }
    100% { background-position: 0% 0; }
}
</style>
</head>
<body>
    <div style='text-align:center;margin-top:50px;'>
		<div class="progress-bar">
			<div class="progress"></div>
		</div>
	</div>
	
</body>
</html>

效果图

在这里插入图片描述
在这里插入图片描述


http://www.kler.cn/a/591579.html

相关文章:

  • Go 语言 `map` 详解
  • 凸优化算法学习笔记:闵可夫斯基和与Slope trick
  • 在k8s中利用Helm部署Prometheus+Grafana和Loki日志系统
  • 什么是时序数据库?
  • mybatis_plus的乐观锁
  • 有了大语言模型还需要 RAG 做什么
  • windows下使用vscode+cline插件体验MCP,体验使用AI控制浏览器,踩坑记录(至少让你节省3个小时弯路版)(喂饭级别)
  • 【第九节】windows sdk编程:通用控件的使用
  • Pygame实现记忆拼图游戏8
  • PHP转GO Go语言环境搭建(Day1) 常见问题及解决方案指南
  • Ubuntu24.04安装ROS2 Jazzy
  • ubuntu下TFTP服务器搭建
  • 宝塔docker切换存储目录
  • 【Pytorch实战教程】拆解PyTorch中的多头注意力:原来Transformer的核心组件可以这样玩
  • leetcode每日一题:对角线上的质数
  • Qt Graphics View
  • Qt 实操记录:打造自己的“ QQ 音乐播放器”
  • 马蜂窝携手腾讯云接入DeepSeek,率先应用于旅游AI智能应用“AI游贵州”
  • Ubuntu “文件系统根目录”上的磁盘空间不足
  • 【操作系统安全】任务4:Windows 系统网络安全实践里常用 DOS 命令