步进纯HTML CSS [英] Stepper Pure HTML CSS

查看:52
本文介绍了步进纯HTML CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm confused about a progress bar that I have created.

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

I want the progress bar to change its background color to blue after setting the class to "active". But I want the progress bar to change its background color before the class is set to "active".

这是我的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;
}

结果是这样

我希望它像这样

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

推荐答案

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

+ CSS

它是相邻的同级组合器.它结合了两个简单的序列具有相同父项的选择器和第二个选择器必须出现在第一个之后立即.

It is Adjacent sibling combinator. It combines two sequences of simple selectors having the same parent and the second one must come IMMEDIATELY after the first.

.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>

这篇关于步进纯HTML CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆