我想创建一个步骤进度条,但我的 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>
最佳答案
如果我理解正确的话,你只需在 &:after 选择器上设置 background-color
而不是 color
&:after {
background-color: #fff;
}
关于javascript - 已设置位置,但 z-index 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52383630/