-
Notifications
You must be signed in to change notification settings - Fork 6
/
053-网页进度条1.html
61 lines (59 loc) · 1.61 KB
/
053-网页进度条1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
*{margin:0;padding:0;}
#progressBox{ width:300px; height:40px; border:1px solid #ccc; position:relative; margin:50px auto;}
#progessBar{ position:absolute; left:0; top:0; z-index:2; width:100%; height:40px; line-height:40px; color:#FFFFFF; text-align:center; font-size:20px; font-weight:bold; clip:rect(0px 0px 40px 0px); background:#5D9098;}
#progessText{ position:absolute; left:0; top:0; z-index:1; width:100%; height:40px; line-height:40px; color:#000000; text-align:center;font-size:20px; font-weight:bold;}
</style>
<script type="text/javascript" src="js/move2.js"></script>
<script type="text/javascript">
window.onload = function()
{
var iNow = 0;
var timer = setInterval(function(){
if(iNow == 100)
{
clearInterval(timer);
}
else
{
iNow += 1;
progressFn(iNow);
}
},30);
function progressFn(cent)
{
var div1 = document.getElementById("progressBox");
var div2 = document.getElementById("progessBar");
var div3 = document.getElementById("progessText");
var allWidth = parseInt(getStyle(div1, "width"));
div2.innerHTML = cent + "%";
div3.innerHTML = cent + "%";
cent/100 * allWidth
div2.style.clip = "rect(0px " +cent/100 * allWidth +"px 40px 0px)"
}
}
function getStyle(obj, attr)
{
if(obj.currentStyle)
{
return obj.currentStyle[attr];
}
else
{
return getComputedStyle(obj, false)[attr];
}
}
</script>
</head>
<body>
<div id="progressBox">
<div id="progessBar">0%</div>
<div id="progessText">0%</div>
</div>
</body>
</html>