我想创建一个进度条,但是CSS出现问题。
我想用圆圈遮住圆圈,但是不行。
演示如下:
HTML:



ol {
  display: table;
  table-layout: fixed;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

li {
  position: relative;
  display: table-cell;
  text-align: center;
}

li:after {
  content: "";
  position: relative;
  z-index: 1000;
  display: block;
  width: 2em;
  height: 2em;
  margin: 0 auto;
  line-height: 2em;
  color: #fff;
  border: 0.2em #e1e1e1 solid;
  border-radius: 100%;
}

li:not(:last-child):before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  display: block;
  width: 100%;
  height: 0.2em;
  background-color: #e1e1e1;
}

<ol>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
</ol>





codepen

最佳答案

只需为您的圈子添加背景:



ol {
  display: table;
  table-layout: fixed;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

li {
  position: relative;
  display: table-cell;
  text-align: center;
}

li:after {
  content: "";
  position: relative;
  z-index: 1000;
  display: block;
  width: 2em;
  height: 2em;
  margin: 0 auto;
  line-height: 2em;
  color: #fff;
  border: 0.2em #e1e1e1 solid;
  border-radius: 100%;
  background:white;               /* add this */
}

li:not(:last-child):before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  display: block;
  width: 100%;
  height: 0.2em;
  background-color: #e1e1e1;
}

<ol>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
  <li>
    Order received
  </li>
</ol>

关于javascript - 位置已设置,但z-index无效,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52383630/

10-10 15:38