Skip to content

Instantly share code, notes, and snippets.

@rainyjune
Last active December 18, 2015 14:09
Show Gist options
  • Save rainyjune/5795158 to your computer and use it in GitHub Desktop.
Save rainyjune/5795158 to your computer and use it in GitHub Desktop.
进度条
#loadbar {
width: 280px;
background-color: #000;
border: 1px solid #000;
}
#bar {
display: block;
font-family: arial;
font-size: 12px;
background-color: #00d0ff;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Progress bar</title>
<link href="blue.css" id="c" rel="stylesheet">
<script>
var i = 0;
var time;
function startbar(){
time = setInterval(setbar, 500);
}
function setbar(){
i += 5;
if (i>=100) {
clearInterval(time);
}
document.getElementById('bar').style.width = i + '%';
document.getElementById('bar').innerHTML = i + '%';
}
</script>
</head>
<body onLoad = "startbar();">
<div id="loadbar">
<strong id="bar" style="width: 30%;">30%</strong>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment