Progress bar made of solid line, with dots as steps

后端 未结 6 1762
[愿得一人]
[愿得一人] 2020-12-01 22:04

I\'m trying to create a vertical progress-bar, with 8 dots on a solid line (with the 8th on the end), where every dot stands for one step in the process. See attached screen

6条回答
  •  独厮守ぢ
    2020-12-01 22:17

    My solution is similar to @Stewartside's, except it uses Flexbox to position everything equally. It's also really easy to change the height.

    ul.progress-bar {
      height: 300px;
      list-style: none;
      margin: 0;
      padding: 0;
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      overflow: hidden;
    }
    ul.progress-bar::after {
      content: "";
      position: absolute;
      top: 0;
      left: 5px;
      background: #777;
      width: 5px;
      height: 100vh;
    }
    ul.progress-bar li {
      background: #000;
      border-radius: 100px;
      width: 15px;
      height: 15px;
      z-index: 1;
      position: relative;
    }
    ul.progress-bar li.stop ~ li {
      background: #777;
    }
    ul.progress-bar li.stop ~ li::after {
      height: 0;
    }
    ul.progress-bar li::after {
      content: "";
      position: absolute;
      bottom: 0;
      left: 5px;
      background: #000;
      width: 5px;
      height: 100vh;
    }

    For some reason, the bottom segment doesn't seem to show up in the stacksnippet, so here it is on jsfiddle.

提交回复
热议问题