【问题标题】:Responsive Progress Bar Vertical Alignment响应式进度条垂直对齐
【发布时间】:2020-09-27 09:44:03
【问题描述】:

我有一个响应式多步进度条,link here 和下面的代码 sn-p;

.multi-steps > li.is-active:before, .multi-steps > li.is-active ~ li:before {
  content: counter(stepNum);
  font-family: inherit;
  font-weight: 700;
}
.multi-steps > li.is-active:after, .multi-steps > li.is-active ~ li:after {
  background-color: #ededed;
}

.multi-steps {
  display: table;
  table-layout: fixed;
  width: 100%;
}
.multi-steps > li {
  counter-increment: stepNum;
  text-align: center;
  display: table-cell;
  position: relative;
  color: tomato;
}
.multi-steps > li:before {
  content: '\f00c';
  content: '\2713;';
  content: '\10003';
  content: '\10004';
  content: '\2713';
  display: block;
  margin: 0 auto 4px;
  background-color: #fff;
  width: 36px;
  height: 36px;
  line-height: 32px;
  text-align: center;
  font-weight: bold;
  border-width: 2px;
  border-style: solid;
  border-color: tomato;
  border-radius: 50%;
}
.multi-steps > li:after {
  content: '';
  height: 2px;
  width: 100%;
  background-color: tomato;
  position: absolute;
  top: 16px;
  left: 50%;
  z-index: -1;
}
.multi-steps > li:last-child:after {
  display: none;
}
.multi-steps > li.is-active:before {
  background-color: #fff;
  border-color: tomato;
}
.multi-steps > li.is-active ~ li {
  color: #808080;
}
.multi-steps > li.is-active ~ li:before {
  background-color: #ededed;
  border-color: #ededed;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
  <br /><br />
  <ul class="list-unstyled multi-steps">
    <li>Start</li>
    <li class="is-active">First Step</li>
    <li>Middle Stage</li>
    <li>Finish</li>
  </ul>
</div>

这很好用,但在较小的屏幕上(例如 max-device-width: 480px),纵向模式我想垂直堆叠步骤。

我怎样才能做到这一点?

【问题讨论】:

    标签: html css twitter-bootstrap responsive-design


    【解决方案1】:

    在文本周围添加一个&lt;span&gt; 元素,使用这个CSS

    .multi-steps > li {
        display: block;
        position: relative;
        padding-bottom: 45px;
    }
    
    .multi-steps > li:before {
        content: '\f00c';
        content: '\2713;';
        content: '\10003';
        content: '\10004';
        content: '\2713';
        display: block;
        margin: 0 auto 4px;
        background-color: #fff;
        width: 36px;
        height: 36px;
        line-height: 32px;
        text-align: center;
        font-weight: bold;
        border-width: 2px;
        border-style: solid;
        border-color: tomato;
        border-radius: 50%;
    }
    
    .multi-steps > li:after {
        content: '';
        height: 2px;
        width: 100%;
        background-color: tomato;
        position: absolute;
        left: 50%;
        z-index: -1;
        display: inline-block;
        top: 0;
        left: 50%;
        width: 3px;
        height: 105px;
    }
    
    .multi-steps > li span.step {
        margin-left: 50px;
        position: relative;
        top: 20px;
    }
    

    【讨论】:

      【解决方案2】:

      在您的媒体查询中,将.multi-steps &gt; li 元素上的display: table-cell 更改为display: block。这应该让你接近你想要实现的目标。您还需要应用一些额外的样式来整理它。希望有帮助。

      例如

      .multi-steps > li {
        display: block;
      }
      

      【讨论】:

      • 感谢display: block; 上的提示,还有其他关于“额外的样式只是为了整理它”的提示吗?
      猜你喜欢
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 2018-12-21
      • 1970-01-01
      • 2014-02-08
      • 1970-01-01
      • 1970-01-01
      • 2021-07-11
      相关资源
      最近更新 更多