从我的代码中可以看到,进度条不会增加偶数个单位.我需要容器保持响应,但进度条要增加偶数个单位.
function increaseProgress() {
var progressBar = document.querySelector(".progress-bar")
var currWidth = progressBar.clientWidth;
progressBar.style.width = currWidth + 10 + "%";
}
.progress-container {
width: 100%;
height: 20px;
outline: solid 2px #ccc;
border-radius: 20px;
}
.progress-bar {
width: 0;
height: inherit;
background: blue;
border-radius: 20px;
}
<div class="progress-container">
<div class="progress-bar"></div>
</div>
<button onclick="increaseProgress()">Click to increase</button>