我有一个嵌套的表,我必须在其中显示文本的工具提示。我已经在jsfiddle中提取了问题,问题是即使我设置Block 2.1 Content
非常大,我也无法将蓝色元素定位在z-index
之上。
这里再次使用html和css代码:
.block {
display: block;
}
.content {
border: 1px solid #ccc;
padding: 2px 5px;
box-shadow: 5px 5px 10px black;
height: 30px;
width: 90%;
line-height: 30px
}
.block1_content {
z-index: 3;
position: relative;
background: white;
}
.block2_content {
z-index: 2;
margin-left: 10px;
position: relative;
background: #ccc;
}
.tooltip {
position: absolute;
display: block;
background: blue;
color: white;
height: 40px;
width: 100px;
z-index: 99999;
padding: 5px 10px;
top: 15px
}
<div class="block1 block">
<div class="block1_content content">Block 1 Content</div>
<div class="block2 block">
<div class="block2_content content">
Block2 Content
<div class="tooltip">Tooltip</div>
</div>
</div>
</div>
<div class="block1 block">
<div class="block1_content content">Block 2.1 Content</div>
<div class="block2 block">
<div class="block2_content content"> Block 2.2 Content</div>
</div>
</div>
编辑
Here根据要求提供了一些有点复杂的代码/问题版本。
希望这能帮助你。谢谢
.block {
display: block;
}
.relative{
position: relative
}
.content {
border: 1px solid #ccc;
padding: 2px 5px;
box-shadow: 5px 5px 10px black;
height: 30px;
width: 90%;
line-height: 30px
}
.block1_content {
z-index: 3;
position: relative;
background: white;
}
.block2_content {
z-index: 2;
margin-left: 10px;
position: relative;
background: #ccc;
}
.tooltip {
position: absolute;
display: block;
background: blue;
color: white;
height: 40px;
width: 100px;
z-index: 99999;
padding: 5px 10px;
top: 15px
}
<div class="block1 block">
<div class="block1_content content">Block 1 Content</div>
<div class="block2 block">
<div class="block2_content content">
Block2 Content
</div>
</div>
</div>
<div class="block1 block relative">
<div class="tooltip">Tooltip</div>
<div class="block1_content content">Block 2.1 Content</div>
<div class="block2 block">
<div class="block2_content content"> Block 2.2 Content</div>
</div>
</div>