z-index不起作用。 我有一个进程div(容器) 在内部进程div中,有连续的链接。 再次,链接分为progress_number div(大数) 和progress_text div(以下简称大号)。 我在每个progress_number div之间添加了条形码。
这是html代码
<div class="process">
<a href="">
<div class="process_number">1</div>
<div class="process_text">text1</div>
</a>
<a href="">
<div class="process_number">2</div>
<div class="process_text">text2</div>
</a>
<a href="" class="process_selected">
<div class="process_number">3</div>
<div class="process_text">text3</div>
</a>
<a href="">
<div class="process_number">4</div>
<div class="process_text">text4</div>
</a>
<a href="">
<div class="process_number">5</div>
<div class="process_text">text5</div>
</a>
</div>
这是css代码。
.process{
width:100%;
height:160px;
border-bottom:1px solid #c4cdd2;
margin-top:35px;
z-index:;
}
.process a{
text-align:center;
text-decoration:none;
display:inline-block;
margin-left:186.5px;
position: relative;
}
.process a:first-child{
margin-left:50px;
}
.process .process_number{
height:75px;
width:75px;
font-size:47px;
font-weight:bold;
border: 1px solid #47a5d8;
border-radius:100%;
color: #47a5d8;
background-color:#fff;
text-align:center;
line-height:170%;
z-index:;
}
.process .process_text{
font-size:15px;
font-weight:bold;
color: #c4cdd2;
margin-top:10px;
}
.process .process_number::before{
content:'';
position:absolute;
top:33px;
right:55px;
width:250px;
height:10px;
background-color:#47a5d8;
z-index:1;
}
.process a:first-child .process_number::before{
display:none;
}
.process_selected .process_number{
color:#fff;
background-color:#47a5d8;
}
.process_selected ~ a .process_number{
color:#c4cdd2;
background-color:#fff;
border-color:#c4cdd2;
}
.process_selected ~ a .process_number::before{
background-color:#c4cdd2;
}
.process_selected .process_text{
color:#47a5d8;
}
现在我想隐藏大圆有界数字(.process_number)后面的栏(.process_number :: before)。 我已经尝试正确修改z-index,但每次尝试任何元素都失败了。 请给我一些建议。
答案 0 :(得分:0)
我看到将 z-index:-1 设置为 .process .process_number ::之前只是这样做。
.process{
width:100%;
height:160px;
border-bottom:1px solid #c4cdd2;
margin-top:35px;
z-index:;
}
.process a{
text-align:center;
text-decoration:none;
display:inline-block;
margin-left:186.5px;
position: relative;
}
.process a:first-child{
margin-left:50px;
}
.process .process_number{
height:75px;
width:75px;
font-size:47px;
font-weight:bold;
border: 1px solid #47a5d8;
border-radius:100%;
color: #47a5d8;
background-color:#fff;
text-align:center;
line-height:170%;
z-index:;
}
.process .process_text{
font-size:15px;
font-weight:bold;
color: #c4cdd2;
margin-top:10px;
}
.process .process_number::before{
content:'';
position:absolute;
top:33px;
right:55px;
width:250px;
height:10px;
background-color:#47a5d8;
z-index:-1;
}
.process a:first-child .process_number::before{
display:none;
}
.process_selected .process_number{
color:#fff;
background-color:#47a5d8;
}
.process_selected ~ a .process_number{
color:#c4cdd2;
background-color:#fff;
border-color:#c4cdd2;
}
.process_selected ~ a .process_number::before{
background-color:#c4cdd2;
}
.process_selected .process_text{
color:#47a5d8;
}
&#13;
<div class="process">
<a href="">
<div class="process_number">1</div>
<div class="process_text">text1</div>
</a>
<a href="">
<div class="process_number">2</div>
<div class="process_text">text2</div>
</a>
<a href="" class="process_selected">
<div class="process_number">3</div>
<div class="process_text">text3</div>
</a>
<a href="">
<div class="process_number">4</div>
<div class="process_text">text4</div>
</a>
<a href="">
<div class="process_number">5</div>
<div class="process_text">text5</div>
</a>
</div>
&#13;
答案 1 :(得分:0)
而不是将z-index 1添加到.process .process_number::before
添加z-index:-1
,尝试以下更新的代码。
.process{
width:100%;
height:160px;
border-bottom:1px solid #c4cdd2;
margin-top:35px;
}
.process a{
text-align:center;
text-decoration:none;
position: relative;
margin-left:100px;
display:inline-block;
}
.process a:first-child{
margin-left:0px;
}
.process .process_number{
height:75px;
width:75px;
font-size:47px;
font-weight:bold;
border: 1px solid #47a5d8;
border-radius:100%;
color: #47a5d8;
background-color:#fff;
text-align:center;
line-height:170%;
z-index:9;
}
.process .process_text{
font-size:15px;
font-weight:bold;
color: #c4cdd2;
margin-top:10px;
}
.process .process_number::before{
content:'';
position:absolute;
top:33px;
right:55px;
width:200px;
height:10px;
background-color:#47a5d8;
z-index:-1;
}
.process a:first-child .process_number::before{
display:none;
}
.process_selected .process_number{
color:#fff;
background-color:#47a5d8;
}
.process_selected ~ a .process_number{
color:#c4cdd2;
background-color:#fff;
border-color:#c4cdd2;
}
.process_selected ~ a .process_number::before{
background-color:#c4cdd2;
}
.process_selected .process_text{
color:#47a5d8;
}
<div class="process">
<a href="">
<div class="process_number">1</div>
<div class="process_text">text1</div>
</a>
<a href="">
<div class="process_number">2</div>
<div class="process_text">text2</div>
</a>
<a href="" class="process_selected">
<div class="process_number">3</div>
<div class="process_text">text3</div>
</a>
<a href="">
<div class="process_number">4</div>
<div class="process_text">text4</div>
</a>
<a href="">
<div class="process_number">5</div>
<div class="process_text">text5</div>
</a>
</div>
答案 2 :(得分:0)
您需要将position: relative
(或绝对)添加到任何具有z-index的类