html5分步骤填写表单,填写表单分步步骤进度条

本文详细介绍了如何使用原生JavaScript为填写表单过程创建一个分步进度条。通过一步步的代码示例,展示了如何设置验证身份、重置密码等步骤,并更新进度条显示。适合前端开发者学习JavaScript动态效果的实现。
摘要由CSDN通过智能技术生成

填写表单分步步骤进度条

使用原生JS实现填写表单分步步骤进度条

效果图如下所示:

dfad14aa73b10cad27a5f89ef86cb92b.png 步骤进度条

1

验证身份

2

重设登录密码

3

完成

下一步

#step .step-wrap {

width: 100%;

position: relative;

}

#step .step-bg {

width: 100%;

height: 10px;

border-radius: 5px;

position: absolute;

top: 10px;

left: 0;

background-color: lightgrey;

}

#step .step-progress {

width: 33.33%;

height: 10px;

border-radius: 5px;

position: absolute;

top: 10px;

left: 0;

background-color: aqua;

}

#step .step {

display: inline-block;

}

#step .step-item {

width: 33.33%;

margin-bottom: 10px;

display: inline-block;

position: absolute;

top: 0;

}

#step .step-item .setp-item-title {

font-size: 14px;

text-align: center;

}

#step .step-item.active .setp-item-num {

background-color: aqua;

}

#step .step .step-item .setp-item-num {

line-height: 30px;

margin-left: 44%;

}

#step .step .step-item:nth-child(1) {

left: 0;

}

#step .step .step-item:nth-child(2) {

left: 33.33%;

}

#step .step .step-item:nth-child(3) {

left: 66.66%;

}

#step .step .setp-item-num {

width: 30px;

height: 30px;

background-color: lightgrey;

border-radius: 50%;

text-align: center;

padding: 3px;

}

.step-next {

width: 200px;

margin: 40px auto;

}

#nextStep {

display: block;

height: 30px;

width: 100%;

}

var progress = (function () {

var step = document.getElementById('step');

var step_progress = step.getElementsByClassName('step-progress')[0];

var step_item = step.getElementsByClassName('step-item');

var nextStep = document.getElementById('nextStep');

var count = 1;// 计数器

var Event = function () {

nextStep.onclick = function () {

if (count++&&count<4) {

if (count === 2) {

step_progress.style.width = '66.66%';

step_item[1].className = 'step-item active';

}

if (count === 3) {

step_progress.style.width = '100%';

step_item[2].className = 'step-item active';

}

}

}

}

return Event;

})();

// 函数调用

progress();

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值