步进纯HTML CSS

时间:2018-08-22 06:27:41

标签: html css stepper

我对自己创建的进度条感到困惑。

我希望进度栏在将类设置为“活动”后将其背景颜色更改为蓝色。但是我希望进度条在班级设置为“活动”之前更改其背景颜色。

这是我的HTML:

<ul class="progressBar">
  <li class="active">Beong Processed</li>
  <li class="active">Waiting for payment</li>
  <li>Paid</li>
</ul>

…和CSS:

.progressBar li.active {
  color: dodgerblue;
}
.progressBar li.active:before {
  border-color: dodgerblue;
  background-color: dodgerblue
}
.progressBar li.active + li:after {
  background-color: dodgerblue;
}

结果是这样

wrong

我希望它像这样

right

https://jsfiddle.net/dedi_wibisono17/c69e374r/2/

3 个答案:

答案 0 :(得分:3)

使用.progressBar .active:after 而不是.progressBar li.active + li:after

+ CSS

  

它是相邻的同级组合器。它结合了两个简单的序列   具有相同父级的选择器,第二个必须选择   第一次之后。

.wrapper-progressBar {
    width: 100%
}

.progressBar {
}

.progressBar li {
    list-style-type: none;
    float: left;
    width: 33%;
    position: relative;
    text-align: center;
}

.progressBar li:before {
    content: " ";
    line-height: 30px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    display: block;
    text-align: center;
    margin: 0 auto 10px;
    background-color: white
}

.progressBar li:after {
    content: "";
    position: absolute;
    width: 100%;
    height: 4px;
    background-color: #ddd;
    top: 15px;
    left: -50%;
    z-index: -1;
}

.progressBar li:first-child:after {
    content: none;
}

.progressBar li.active {
    color: dodgerblue;
}

.progressBar li.active:before {
    border-color: dodgerblue;
    background-color: dodgerblue
}

.progressBar .active:after {
    background-color: dodgerblue;
}
<div class="row">
  <div class="col-xs-12 col-md-8 offset-md-2 block border">
    <div class="wrapper-progressBar">
      <ul class="progressBar">
        <li class="active">Beong Processed</li>
        <li class="active">Waiting for payment</li>
        <li>Paid</li>
      </ul>
    </div>
  </div>
</div>

答案 1 :(得分:2)

尝试将您的.progressBar li.active + li:after选择器更改为.progressBar li.active:after

.wrapper-progressBar {
    width: 100%
}

.progressBar {
}

.progressBar li {
    list-style-type: none;
    float: left;
    width: 33%;
    position: relative;
    text-align: center;
}

.progressBar li:before {
    content: " ";
    line-height: 30px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    display: block;
    text-align: center;
    margin: 0 auto 10px;
    background-color: white
}

.progressBar li:after {
    content: "";
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #ddd;
    top: 15px;
    left: -50%;
    z-index: -1;
}

.progressBar li:first-child:after {
    content: none;
}

.progressBar li.active {
    color: dodgerblue;
}

.progressBar li.active:before {
    border-color: dodgerblue;
    background-color: dodgerblue
}

.progressBar li.active:after {
    background-color: dodgerblue;
}
<div class="row">
  <div class="col-xs-12 col-md-8 offset-md-2 block border">
    <div class="wrapper-progressBar">
      <ul class="progressBar">
        <li class="active">Beong Processed</li>
        <li class="active">Waiting for payment</li>
        <li>Paid</li>
      </ul>
    </div>
  </div>
</div>

答案 2 :(得分:1)

根据您的要求,这更像您要求的答案吗?

@objc var TvshowPath2 = NSDictionary()

override func viewDidLoad()
 {
   super.viewDidLoad()

   print(TvshowPath2)
}
.wrapper-progressBar {
    width: 100%
}

.progressBar {
}

.progressBar li {
    list-style-type: none;
    float: left;
    width: 33%;
    position: relative;
    text-align: center;
}

.progressBar li:before {
    content: " ";
    line-height: 30px;
    border-radius: 50%;
    width: 17px;
    height: 17px;
    border: 1px solid #ddd;
    border-left:none;
    display: block;
    text-align: center;
    margin: 8.5px auto 0px;
    background-color: #eee;
}
.progressBar li:after {
    content: "";
    position: absolute;
    width: 97%;
    height: 5px;
    background-color: #eee;
    border: 1px solid #ddd;
    border-right:none;
    top: 15px;
    left: -50%;
    z-index: -1;
}

.progressBar li:first-child:after {
    content: none;
}

.progressBar li.active {
    color: dodgerblue;
}

.progressBar li.active:before {
    border-color: dodgerblue;
    background-color: dodgerblue
}

.progressBar .active:after {
    background-color: dodgerblue;
}