我目前有几个垂直选项卡,它们在向页面内的内容展开时向下展开。随着它们向下扩展,悬停选项卡中的“内容”div会扩展到标签的右侧。我喜欢这种方式,因为我似乎无法让“内容”div出现在其他选项卡上。我会假设这是由于堆叠顺序,因为当我扭转顺序它的工作很好。任何人都可以帮我解决这个问题吗?我已经尝试过z-index和不透明技巧来让它起作用,而且目前还没有。我知道z-index会根据位置和不透明度来改变上下文,但我在这方面的知识是有限的。当你提供可能的解决方案时,你能解释它为什么起作用吗?CSS:堆叠订单问题
代码:
.tab {
background: #0AF;
width: 50px;
height: 150px;
position: absolute;
top: -100px;
border-radius: 5px;
transition: all linear 0.2s;
}
.tab:hover {
top: -5px;
border-bottom-right-radius: 0px;
}
.content {
position: absolute;
left: 0;
width: 50px;
height: 150px;
background: #EEE;
border-radius: 5px;
transition: all linear 0.2s;
opacity: 0;
text-align: center;
color: #222;
}
.content .foot {
position: absolute;
bottom: 0;
margin-left: -50px;
margin-bottom: 5px;
}
.tab:hover > .content, .content:hover {
left: 40px;
width: 300px;
opacity: 1;
border-bottom-left-radius: 0px;
}
.about {
background: #0AF;
}
.social {
left: 80px;
background: #F05;
}
.projects {
left: 150px;
background: #0F5;
}
<div class="tab about">
<div class="content">
<span class="foot">About Me</span>
</div>
</div>
<div class="tab social">
<div class="content">
<span class="foot">Social Media</span>
</div>
</div>
<div class="tab projects">
<div class="content">
<span class="foot">Projects</span>
</div>
</div>
感谢, 杰米
感谢您指出这一点,它让我意识到内容类正在被用作Tab类的子级,从而使z-index与其他选项卡无关。 – lxxtacoxxl