进度条加载器

实线效果如图:


实现过程:
q5.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/q5.js" charset="gbk"></script>
<style type="text/css">
#box {
    width: 1204px;
    height: 84px;
    margin-top: 520px;
    margin-left: 35px;
}

#outter {
    border: groove red 6px;
    width: 1204px;
    height: 44px;
    margin-top: 2px;
    margin-left: 2px;
}

#inside {
    width: 0px;
    height: 40px;
    background-color: #000;
    margin-left: 2px;
    margin-top: 2px;
}

#tip {
    width: 192px;
    height: 20px;
    background-color: gray;
    margin-left: 1024px;
}
</style>

</head>
<body onload="scr()">
    <div id="box">
        <div id="tip">游戏加载进度0.00%...</div>
        <div id="outter">
            <div id="inside"></div>
        </div>
    </div>
</body>
</html>

q5.js

var a = 0, b = 60, c = b / 12;

function show() {
    if (document.getElementById("inside").offsetWidth < 1200) {
        a += c;
        var str = a + "";
        if (str.indexOf(".") == -1) {
            str += ".00";
        } else {
            str = str.substring(0, indexOf(".") + 3);
        }
        document.getElementById("inside").style.width = document
                .getElementById("inside").offsetWidth
                + b + "px";
        document.getElementById("tip").innerHTML = "游戏加载进度" + str + "%...";
    } else {
        document.getElementById("inside").style.width = 1200 + "px";
        stop();
    }
}

var timer;
function scr() {
    timer = window.setInterval(show, 800);
}

function stop() {
    window.clearInterval(timer);
    alert("加载完毕");
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 177,210评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,806评论 4 61
  • 做一个母婴网店 搜罗一些市面上不太好买的好东西 学习儿童心理学等 提升自己 学习烘焙或者厨艺
    手心里的温暖cyp阅读 1,553评论 0 0
  • 公元二零一七年六月十四日,我收到了平板的蓝牙键盘。这样的话,我就可以开始写作了。 其实我是工作时间比较自由的,可...
    黄小四九阅读 2,732评论 0 0
  • 今天是讲师班的最后一天,早上安顿好孩子后就出门了,担心迟到,所以一路上除了在车上的时间,在地面上时就在奔跑,脑子里...
    花花公主阅读 1,819评论 0 0

友情链接更多精彩内容