How to vertically align a progress bar in Twitter Bootstrap?

后端 未结 5 582
天命终不由人
天命终不由人 2020-12-13 07:30

I\'m using the progressbar control of twitter-bootstrap.

I want to align it vertically to look like in the following image:

5条回答
  •  时光说笑
    2020-12-13 08:20

    Bootstrap 3 and Bootstrap 4 solution.

    Demo: https://jsfiddle.net/elijahmurray/7tgh988z/

    I struggled with finding a good solution to this problem for awhile. Ultimately, I ended up writing my own that is semantically similar to how Bootstrap structures their progress bars.

    This solution also doesn't use transform, which I found really messed up a lot of things with positioning when using it. Not to mention, it just got confusing with that.

    HTML

    60% Complete

    CSS

    .progress-bar-vertical {
      width: 20px;
      min-height: 100px;
      margin-right: 20px;
      float: left;
      display: -webkit-box;  /* OLD - iOS 6-, Safari 3.1-6, BB7 */
      display: -ms-flexbox;  /* TWEENER - IE 10 */
      display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
      display: flex;         /* NEW, Spec - Firefox, Chrome, Opera */
      align-items: flex-end;
      -webkit-align-items: flex-end; /* Safari 7.0+ */
    }
    
    .progress-bar-vertical .progress-bar {
      width: 100%;
      height: 0;
      -webkit-transition: height 0.6s ease;
      -o-transition: height 0.6s ease;
      transition: height 0.6s ease;
    }
    

    Vote if this was helpful!

提交回复
热议问题