我已經編碼瞭如下的步驟嚮導。css步驟嚮導z-index不起作用
ul.progress[data-steps="2"] li { width: 49%; }
ul.progress[data-steps="3"] li { width: 33%; }
ul.progress[data-steps="4"] li { width: 24%; }
ul.progress[data-steps="5"] li { width: 19%; }
ul.progress[data-steps="6"] li { width: 16%; }
ul.progress[data-steps="7"] li { width: 14%; }
ul.progress[data-steps="8"] li { width: 12%; }
ul.progress[data-steps="9"] li { width: 11%; }
.progress {
width: 100%;
list-style: none;
list-style-image: none;
padding: 20px 0;
margin:0;
overflow:hidden;
border:2px solid #000;
}
.progress li {
float: left;
text-align: center;
position: relative;
}
.progress .name {
display: block;
vertical-align: bottom;
text-align: center;
margin-bottom: 25px;
color: black;
opacity: 0.3;
}
.progress .step {
color: black;
border: 3px solid silver;
background-color: silver;
border-radius: 50%;
line-height: 1.2;
width: 30px;
height: 30px;
display: inline-block;
z-index: 10;
}
.progress .step span {
opacity: 0.3;
}
.progress .active .name,
.progress .active .step span {
}
.progress .step:before {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
left: 0;
z-index: 9;
}
.progress .step:after {
content: "";
display: block;
background-color: silver;
height: 5px;
width: 50%;
position: absolute;
bottom: 15px;
right: 0;
z-index: 9;
}
.progress li:first-of-type .step:before {
display: none;
}
.progress li:last-of-type .step:after {
display: none;
}
.progress .done .step,
.progress .done .step:before,
.progress .done .step:after,
.progress .active .step,
.progress .active .step:before {
background-color: yellowgreen;
}
.progress .done .step,
.progress .active .step {
border: 3px solid yellowgreen;
}
<div>
<ul class="progress" data-steps="4">
<li class="done">
<span class="name">Foo</span>
<span class="step"><span>1</span></span>
</li>
<li class="done">
<span class="name">Bar</span>
<span class="step"><span>2</span></span>
</li>
<li class="active">
<span class="name">Baz</span>
<span class="step"><span>3</span></span>
</li>
<li>
<span class="name">Quux</span>
<span class="step"><span>4</span></span>
</li>
</ul>
</div>
但是z-index的不起作用。
類「step」的z-index爲10,而「step:before,step:after」之一爲9.
爲什麼「step:after」元素,灰線放在綠色圓圈的上方?
所以我不明白z-索引。
謝謝。
的z-index只適用於定位的元素和你的'.step'元素不是 – j08691
爲什麼不。步驟元素z-index的工作? –
感謝您的幫助。 –