Creating CSS3 Circles connected by lines

前端 未结 8 1352
一个人的身影
一个人的身影 2020-12-02 05:19

I have to implement the following circle and line combination in CSS and I am looking for pointers on how to implement this effectively. The circles and lines should look li

8条回答
  •  误落风尘
    2020-12-02 05:46

    It is not my own but it works quite well and looks elegant, only works with css and you can perzonalize it more. Source http://jsfiddle.net/Misiu/y1Lo3qh1/

    var i = 1;
    $('.progress .circle').removeClass().addClass('circle');
    $('.progress .bar').removeClass().addClass('bar');
    setInterval(function () {
        $('.progress .circle:nth-of-type(' + i + ')').addClass('active');
        $('.progress .circle:nth-of-type(' + (i - 1) + ')').removeClass('active').addClass('done');
        $('.progress .circle:nth-of-type(' + (i - 1) + ') .label').html('✓');
        $('.progress .bar:nth-of-type(' + (i - 1) + ')').addClass('active');
        $('.progress .bar:nth-of-type(' + (i - 2) + ')').removeClass('active').addClass('done');
        i++;
        if (i == 8) {
            $('.progress .circle').removeClass().addClass('circle');
            $('.progress .bar').removeClass().addClass('bar');
            i = 1;
        }
    }, 1000);
    *,
    *:after,
    *:before {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: "Open Sans";
    }
    /* Form Progress */
    
    .progress {
    
      margin: 20px auto;
      text-align: center;
      padding-bottom: 80px;
    }
    .progress .circle,
    .progress .bar {
      display: inline-block;
      background: #fff;
      width: 40px;
      height: 40px;
      border-radius: 40px;
      border: 1px solid #d5d5da;
      vertical-align:top;
    }
    .progress .bar {
      position: relative;
      width: 80px;
      height: 6px;
      margin: 0 -5px 17px -5px;
      border-left: none;
      border-right: none;
      border-radius: 0;
      top:16px;
      vertical-align:top
    }
    .progress .circle .label {
      display: inline-block;
      width: 32px;
      height: 32px;
      line-height: 32px;
      border-radius: 32px;
      margin-top: 3px;
      color: #b5b5ba;
      font-size: 17px;
    }
    .progress .circle .title {
      color: #b5b5ba;
      font-size: 13px;
      line-height: 18px;
      margin-left: -30px;
      display: block;
      width: 100px;
      margin-top: 5px;
    }
    /* Done / Active */
    
    .progress .bar.done,
    .progress .circle.done {
      background: #eee;
    }
    .progress .bar.active {
      background: linear-gradient(to right, #EEE 40%, #FFF 60%);
    }
    .progress .circle.done .label {
      color: #FFF;
      background: #8bc435;
      box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
    }
    .progress .circle.done .title {
      color: #444;
    }
    .progress .circle.active .label {
      color: #FFF;
      background: #0c95be;
      box-shadow: inset 0 0 2px rgba(0, 0, 0, .2);
    }
    .progress .circle.active .title {
      color: #0c95be;
    }
    
    
    
    1 Order
    2 Address
    3 Payment
    4 Review
    5 Finish
    1 Order informations
    2 Order review
    3 Finish

提交回复
热议问题