如何利用jQuery+css做一个倒计时进度条,下面web建站小编给大家简单介绍一下具体实现代码!
html代码:
<div class="progress-bar"> <div class="item"></div> </div> <div class="btn">进度条</div> <div class="count-down"> <div class="item"></div> </div> <div>剩余时间 : <span class="time"></span>s</div>
css代码:
.progress-bar {
width:200px;
height:20px;
background-color:aliceblue;
border-radius:20px;
display:flex;
}
.btn {
margin:20px;
width:70px;
height:30px;
line-height:30px;
text-align:center;
background-color:#bfa;
cursor:pointer;
color:rgb(202,202,90);
}
.progress-bar .item {
width:0;
height:100%;
background-color:rgb(56,148,255);
border-radius:20px;
transition:all 1s;
}
.count-down {
width:200px;
height:20px;
background-color:aliceblue;
border-radius:20px;
display:flex;
}
.count-down .item {
width:100%;
height:100%;
background-color:rgb(56,148,255);
border-radius:20px;
transition:all 0.1s;
}
jquery代码:
var w = 0
let w2 = 100
let t = 50
$('.time').html(t)
$('.btn').on("click", function() {
w += 20
$('.progress-bar .item').css("width", `${w}%`)
console.log(w);
})
let timer = setInterval(() => {
w2 -= 0.2
if (w2 < 0) {
clearInterval(timer)
}
console.log(w2);
$('.count-down .item').css("width", `${w2}%`)
}, 100);
let timer2 = setInterval(() => {
t -= 1
if (t <= 0) {
clearInterval(timer2)
}
$('.time').html(t)
}, 1000);
上面是“jQuery+css做一个倒计时进度条”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3821.html
workflows工作流
ai图片扩大comfyui工作流
一尊白玉猴王ComfyUI工作流
一个质朴的木制窗户上放着各种葫芦、南瓜等
乒乓卡通3d人物
一个女孩骑着一辆生锈的现代摩托车
一个可爱的人形小机器人和一只蜗牛在森林
stvmccrr风格的玫瑰花ComfyUI工作流
奇幻绘画风格:一只巨大蜗牛ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

3d文字动画效果
js导出excel插件(兼容mac电脑Numbers表格)
css3动画loading效果
3d空间行走效果
做一个好玩的时钟翻牌效果
自动打字效果(惊喜在后面)
css3结合svg做一个动态广告
利用CSS3代码编写45款按钮效果











