【发布时间】:2017-07-29 00:02:54
【问题描述】:
为什么 z-index 在表格内不起作用? 我有一个有 4 列的表格,其中一列位于表格之外,因此它看起来像选项卡,但我不能隐藏表格下方选项卡的右侧。
请看这段代码sn-p:
div {
position: relative;
z-index: 5;
width: 70%;
margin: auto;
height: 500px;
background-color: red;
}
table {
border: none;
border-spacing: 0 11px;
width: 100%;
table-layout: fixed;
}
td.tab {
background-color: white;
padding: 15px;
width: 20%;
position: absolute;
z-index: -15;
right: 90%;
}
td.plan {
padding: 15px;
width: 33.3%;
text-align: center;
}
<div class="bottom">
<table>
<tbody>
<tr>
<td class="tab">test</td>
<td class="plan">test</td>
<td class="plan">test</td>
<td class="plan">test</td>
</tr>
<tr>
<td class="tab">test</td>
<td class="plan">test</td>
<td class="plan">test</td>
<td class="plan">test</td>
</tr>
<tr>
<td class="tab">test</td>
<td class="plan">test</td>
<td class="plan">test</td>
<td class="plan">test</td>
</tr>
</tbody>
</table>
</div>
编辑:我不需要标签,我会将我们的计划添加到网站。 我更新了fiddle,我想去掉标签右侧的这个阴影。
【问题讨论】:
-
为什么不使用
td.tab { width: 10%;}和right: 100%;的宽度 -
为什么要隐藏表格下的一半标签?如果您只是将它们留在原来的位置,只是使用不同的背景颜色,在视觉上会有什么不同吗?
-
@Toxide82,我更新了帖子,看看新的小提琴,谢谢男人
-
在第一个值的盒子阴影上将其更改为
-5px;,这会将阴影从右侧拉到左侧
标签: html css html-table css-position z-index