如何利用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工作流
金属埃及人ComfyUI工作流
一个男人正走进科幻的大门ComfyUI工作流
彩色雄鹰玉雕ComfyUI工作流
小鸟在黑暗的天空中优雅地跳舞
哈利波特魔法ComfyUI工作流
城市里出现一只可爱的小生物ComfyUI工作流
《翅膀之王:鸡的团契》海报ComfyUI工作流
一位穿着长袍的强大法师ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

Inspira UI:免费开源、3D 动画炸裂的Vue3 / Nuxt组件库
解决父组件向iframe子组件传参失败或iframe子组件向父组件传参失败
Seed Prover 1.5:字节跳动Seed团队研发的形式化数学推理模型
TranslateGemma:谷歌Gemma 3生态力作,多模态开源翻译模型
推荐一款2023年最火的前端开源项目——Shadcn-UI














