加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 业界 > 正文

jquery+css 实现简单的进度条效果

发布时间:2018-08-23 12:34:00 所属栏目:业界 来源:站长网
导读:jquery其实是有个进度条插件的,叫做jqueryprogressbar.js,可是想练习一下,就没有用,自己写了点代码。这个代码其实是参考别人的,因为自己的JS基础不是很好。 其实我本来的计划是做网页设计师的,可是没有人认为我设计的好,哥到现在还没有工作,发泄一

jquery其实是有个进度条插件的,叫做jqueryprogressbar.js,可是想练习一下,就没有用,自己写了点代码。这个代码其实是参考别人的,因为自己的JS基础不是很好。

其实我本来的计划是做网页设计师的,可是没有人认为我设计的好,哥到现在还没有工作,发泄一下,不多说了。

效果图

jquery+css 实现简单的进度条效果

需要用到的图片:

背景图片:

jquery+css 实现简单的进度条效果

进度显示图片:

jquery+css 实现简单的进度条效果

网页结构:

<div id="center">
<div id="message"></div>
<div id="loading"><div>
</div>

#center{
margin:50px auto;
width:400px;
}
#loading{
width:397px;
height:49px;
background:url(bak.png) no-repeat;
}
#loading div{
width:0px;
height:48px;
background:url(pro.png) no-repeat;
color:#fff;
text-align:center;
font-family:Tahoma;
font-size:18px;
line-height:48px;
}
#message{
width:200px;
height:35px;
font-family:Tahoma;
font-size:12px;
background-color:#d8e7f0;
border:1px solid #187CBE;
display:none;
line-height:35px;
text-align:center;
margin-bottom:10px;
margin-left:50px;
JavaScript代码:

代码:

<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript">
var progress_id = "loading";
function SetProgress(progress) {
if (progress) {
$("#" + progress_id + " > div").css("width", String(progress) + "%"); //控制#loading div宽度
$("#" + progress_id + " > div").html(String(progress) + "%"); //显示百分比
}
}

var i = 0;
function doProgress() {
if (i > 100) {
$("#message").html("加载完毕!").fadeIn("slow");//加载完毕提示
return;
}

if (i <= 100) {
setTimeout("doProgress()", 100);
SetProgress(i);
i++;
}
}

$(document).ready(function() {
doProgress();
});
</script>

出处:http://www.cnblogs.com/gxll1314/

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读