【发布时间】:2020-05-04 19:03:49
【问题描述】:
我在this site 上看到了这个进度条码。
我想做的是,倒计时 3 分钟,并显示还剩多少分钟和秒。因此,我不想显示百分比,而是显示剩余时间。
我使用以下代码:
JS
progress(100, $('#progressBar')); // This is what the timer should update each second
function progress(percent, $element) {
var progressBarWidth = percent * $element.width() / 100;
$element.find('div').animate({ width: progressBarWidth }, 500).html(percent + " minutes/seconds to go");
};
HTML
<div id="progressBar">
<div></div>
</div>
CSS
#progressBar {
width: 923px;
margin: 10px auto;
height: 22px;
background-color: #0A5F44;
}
#progressBar div {
height: 100%;
text-align: right;
padding: 0 10px;
line-height: 22px; /* same as #progressBar height if we want text middle aligned */
width: 0;
background-color: #CBEA00;
}
【问题讨论】:
-
百分比是可以的,我想可视化。但文字必须显示还剩多少时间。