day02 进度条

这里写目录标题

进度条

在这里插入图片描述
2.在这里插入图片描述
3.
在这里插入图片描述

html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>进度条</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div class="container">
        <div class="container-progress">
            <div class="step active">
                <span>1</span>
            </div>
            <div class="line"></div>
            <div class="step">
                <span>2</span>
            </div>
            <div class="line"></div>
            <div class="step">
                <span>3</span>
            </div>
            <div class="line"></div>
            <div class="step">
                <span>4</span>
            </div>
        </div>
        <button disabled>pre</button>
        <button>next</button>
    </div>


    <script src="index.js"></script>
</body>
</html>

css


*{
  margin:0;
  padding:0;
}
body{
  display: flex;
  justify-content: center;
  align-items: center;
  height: 90vh;
}
.container{
  text-align: center;
  .container-progress{
    display: flex;
    .step{
      box-sizing: border-box;
      width: 43px;
      height: 43px;
      border: 3px solid #e0e0e0;
      border-radius: 50%;
      text-align: center;
      line-height: 40px;
    }
    .line{
      width: 50px;
      height: 2px;
      background: #e0e0e0;
      margin: 20px 0;
    }
    .active{
      background:  #3498db;
      border:  #3498db;
      transition: background-color ease-in 0.7s;
    }
  }
  button{
    width: 80px;
    height: 40px;
    margin: 30px;
    color: #fff;
    border:0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    background-color:  #3498db;
  }
  button:active{
    transform: scale(0.98);
  }
  button:focus{
    outline: 0;
  }
  button:disabled{
    background-color: #e0e0e0;
    cursor: not-allowed;
  }

}

js


window.onload = function (){
    const circle = document.getElementsByClassName('step');
    const line = document.getElementsByClassName('line');
    const btns = document.getElementsByTagName('button');
    const pre = btns[0], next = btns[1];
    let index = 0;
    next.onclick = function (){
        line[index].classList.add('active');
        circle[index+1].classList.add('active');
        index++;
        if(index!=0){
            pre.disabled = false;
        }
        if(index==3){
            next.disabled = true;
        }
    }
    pre.onclick = function (){
        line[index-1].classList.remove('active');
        circle[index].classList.remove('active');
        index--;
        if(index!=3){
            next.disabled = false;
        }
        if(index==0){
            pre.disabled = true;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值