Web前端 | 进度条 | 动态进度条 | IOS进度条 | 仿IOS进度条

一、Html代码

<!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>动态进度条</title>
    <link href="./Content/Site.css" rel="stylesheet"/>
</head>
<body onload="Load()">
    <!-- loading - Start-->
    <div id="load">
        <div id="loading">
            <div id="loadingText" class="loadingText">0 %</div>
            <div class="loading">
                <div id="loadingBar" class="loadingBar"></div>
            </div>
        </div>
    </div>
    <!-- loading - End -->
    <div id="body">
        <h3>主页要显示的内容</h3>
    </div>
    <script src="./Scripts/Layout.js"></script>
    <script src="./Scripts/jquery-3.6.0.min.js"></script>
</body>
</html>

二、Css代码

/* Others */
* { margin:0px; padding:0px;}
body { font: 15px "Microsoft YaHei", Arial, Helvetica, sans-serif; color: #555; background: #f1f1f1; line-height: 1.5; text-align:center; padding-top:0px; padding-bottom:0px;}
img { border:0px; display:block;}
ul, li { list-style:none;}
a { text-decoration:none; color:#ccc;}
   a:hover { text-decoration:none; color:#ccc;}
#body{ display: none;}
/*loading*/
body #load{ width:100%;height:100%;}
body #loading{ width:60%; margin:600px auto 0px; }
.loadingText{ display:block; font-size:26px; font-weight:600; margin:0px auto; color:black; box-sizing:content-box;}
.loading{ height:5px; background-color:#e5e9eb; border-radius:0; box-shadow:none;margin-bottom:30px; overflow:visible;}
.loadingBar{ height:5px; background-color:#000000; position:relative; background-image:linear-gradient(to right,#4cd964,#5ac8fa,#007aff,#34aadc,#5856d6,#ff2d55);}
@-webkit-keyframes animate-positive{ 0%{ width:0%;}}
@keyframes animate-positive{ 0% { width:0%;}}
/* #body */
#body h3{ padding-top: 400px;}

三、jQuery代码

//动画加载事件
function Load() {
    //初始化进度
    var value = 0;
    //初始化进度元素宽度
    loadingBar.style.width = 0;
    //加载计时器
    var timer = setInterval(function () {
        //判断当前进度
        if (value >= 101) {
            setTimeout(function () {
                //隐藏动画
                $("#load").hide();
                //显示页面
                $("#body").show();
            }, 800);
            //清除计时器
            clearInterval(timer);
        } else {
            //修改进度元素宽度
            loadingBar.style.width = value + "%";
            //修改文本元素
            loadingText.innerText = value + " %";
        }
        value++;
    }, 40);
};
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Vin Cente

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

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

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

打赏作者

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

抵扣说明:

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

余额充值