css实现进度条JS动态设置进度条百分⽐
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.father {
width:300px;
height:20px;
background: #784C2D;
border-radius:15px;
margin:100px auto;
padding:5px;
}
#Son {
width:100%;
height:100%;
background: #F2CE28;
border-radius:10px;
}
</style>
<body>
<div class="father">
<div id="Son"></div>
</div>
margin属性值可以为百分比</body>
</html>
<script>
var Son = ElementById("Son")
Son.style.width =Percentage(40,100)+"%"
function Percentage(current, total){
// 数量/总数量*100  公式
return current / total *100
}
</script>
效果

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。