【发布时间】:2020-10-07 11:55:50
【问题描述】:
我有一个包含一些行的表格,每一行都有一个“更多选项”按钮,单击该按钮会打开一个包含选项的下拉菜单。但是在最后一行中,选项下拉列表仍然垂直溢出视口。我看到了一个类似的问题here,但我没有使用引导程序。 Bootstrap 解决方案使用 JS 使用变换计算和定位元素。但是有什么方法可以只用 CSS 来做到这一点?
这是我的表结构:
<table>
<tbody>
<tr>
<td>
...
</td>
<td>
...
</td>
<td>
...
</td>
<td>
...
</td>
<td>
...
</td>
<td>
...
</td>
<td>
<svg class="ICON HERE..."></svg>
<ul class="options">
<li><span>Salvar a biblioteca</span></li>
<li><span>Adicionar a fila</span></li>
<li><span>Adicionar a playlist</span></li>
<li><span>Remover dessa playlist</span></li>
<li><span>Desabilitar nessa playlist</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<style>
table{
width: 100%;
table-layout: fixed;
}
table tbody tr td:nth-child(7) {
width: 50px;
}
tr td:last-child {
overflow: visible;
position: relative;
}
table tbody tr td {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
table tbody tr td {
font-size: 16px;
text-align: left;
vertical-align: middle;
padding: 10px 15px;
color: #bbb;
}
.options{
border: 1px solid #3D4466;
border-radius: 14px;
margin: 10px 0 0 0;
box-shadow: 0 6px 12px 0px rgba(0,0,0,0.16);
transition: .5s opacity;
position: absolute;
z-index: 2;
min-width: 175px;
background: #252A41;
top: 0;
left: inherit;
right: 100%;
bottom: inherit;
}
</style>
【问题讨论】:
-
能否提供代码。
-
请提供最少的代码来重现您面临的问题,以便人们可以更好更快地帮助您
-
你隐藏了你的视口垂直滚动条吗?
-
不,我没有隐藏它。
标签: javascript html css