I have a table with some rows and each row has a "more options" button that when clicked, opens a dropdown with the options. But in the last row, the options dropdown persists to overflow the viewport vertically. I saw a similar question here, but i'm not using bootstrap. The Bootstrap solution used JS to calculate and position the element using transform. But there is any way to do that with just CSS?
Here its my table structure:
<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>