gpt4 book ai didi

css - 步骤进度条图标

转载 作者:太空宇宙 更新时间:2023-11-04 06:46:33 24 4
gpt4 key购买 nike

我正在尝试设置一个只有当前步骤图标的小步骤进度条。到目前为止,我已经有了各种默认图标,但无法弄清楚如何为非事件步骤清除它。

在下面的代码中,我尝试使用伪类,但似乎没有用。我想知道是否有人能指出我正确的方向。谢谢!

    .step-indicator-container {
width: 600px;
margin: 100px auto;
}

.step-indicator li {
list-style-type: none;
width: 33.33%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}

.step-indicator li:before {
font-family: "FontAwesome";
content: "\f276";
width: 30px;
height: 30px;
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}

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

.step-indicator li:not(.active):nth-of-type(2) > *::before {
content: none;
}

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

.step-indicator li.active {
color: #0052e7;
}

.step-indicator li.active:before {
border-color: #0052e7;
}

.step-indicator li.active+li:after {
background-color: #0052e7;
}

最佳答案

对于这个答案,我假设以下是您的 HTML 结构:

<div class="step-indicator-container">
<ul class="step-indicator">
<li></li>
<li class="active"></li>
<li></li>
</ul>
</div>

问题在于以下声明:

.step-indicator li:not(.active):nth-of-type(2) > *::before {
content: none;
}

这是针对 li 标签的 后代::before。但是,您实际上将符号放在 li 标记本身的 ::before 上,而不是后代。因此,这就是您需要瞄准的目标。此外,content: none 消除了 ::before,因此您实际上需要 content: ""。这是我认为您真正想要的:

.step-indicator li:not(.active)::before {
content: "";
}

这是完整的代码片段(注意我用 $ 替换了你的符号):

.step-indicator-container {
width: 600px;
margin: 100px auto;
}

.step-indicator li {
list-style-type: none;
width: 33.33%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}

.step-indicator li:before {
content: "$";
width: 30px;
height: 30px;
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}

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

.step-indicator li:not(.active)::before {
content: "";
}

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

.step-indicator li.active {
color: #0052e7;
}

.step-indicator li.active:before {
border-color: #0052e7;
}

.step-indicator li.active+li:after {
background-color: #0052e7;
}
<div class="step-indicator-container">
<ul class="step-indicator">
<li></li>
<li class="active"></li>
<li></li>
</ul>
</div>

关于css - 步骤进度条图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53245334/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com