Skip to content

Instantly share code, notes, and snippets.

@alexzhou
Created November 5, 2013 03:57
Show Gist options
  • Save alexzhou/7313650 to your computer and use it in GitHub Desktop.
Save alexzhou/7313650 to your computer and use it in GitHub Desktop.
使用背景图来实现环形进度条,背景图片地址在 http://www.mythou.com/demo/images/progressbar_mid.png
<!DOCTYPE html>
<html>
<head>
<title>circle progressbar</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
function setValue(value){
$(".progress-bar").css('background-position',-value*54 + 2 +'px 2px');
$(".progress-value em").text(value);
}
$("#range").mousemove(function(){
setValue(this.value);
})
setValue($("#range").val());
})
</script>
</head>
<body>
<style type="text/css">
.progress-bar{
height: 50px;
width: 55px;
position: relative;
background: url("images/progressbar_mid.png") no-repeat 0px 2px;
}
.progress-value{
position: absolute;
left: 10px;
top: 15px;
font-family: "微软雅黑";
font-size: 12px;
}
</style>
<input id="range" type="range" min="0" max="100" />
<div class="progress-bar">
<span class="progress-value"><em>100</em>%</span>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment