Okay, so I have a table with x amount of rows in it that can be dependable on how much data is in that table, the table is designed to scroll when the rows are more than the view height.
On hover of a menu cell in the table, a little drop down menu appears underneath the icon, it needs to float over everything else though and not simply 'push' the rest of the content down.
I've set absolute positioning on the dropdown and this seems to work UNTIL i start scrolling the table, and then the menu appears to be positioned relative to the original positions of the rows on the page if there were no scroll bars.
.tableDropMenuContainerContent {
min-height: auto;
min-width: 150px;
position: absolute;
background-color: white;
display: none;
}
Is there anyway to set this so that the menu behaves like the first few rows for the whole rows in the table?
$(document).ready(function() {
$('.extMenuCell').hover(function() {
$(this).css('background-color', '#e1d9ff');
$(this).children('.tableDropMenuContainerContent').css('display', 'block');
});
$('.extMenuCell').mouseleave(function() {
$(this).css('background-color', '#eaf3ff');
$(this).children('.tableDropMenuContainerContent').css('display', 'none');
});
});
.testTable {
width: 400px;
height: 200px;
overflow: scroll;
}
.panel {
background: #fff;
-webkit-box-shadow: 0 0 2px 0 rgba(0, 0, 0, .12), 0 2px 2px 0 rgba(0, 0, 0, .24);
box-shadow: 0 0 2px 0 rgba(0, 0, 0, .12), 0 2px 2px 0 rgba(0, 0, 0, .24);
border-radius: 3px;
border: none;
margin-bottom: 20px;
}
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 1rem;
border-radius: 2px;
}
table thead th {
padding: 30px;
}
table thead th {
padding: 15px 5px;
font-weight: 500;
text-align: left;
}
tfoot td,
tfoot th,
thead td,
thead th {
padding: .5rem .625rem .625rem;
font-weight: 700;
text-align: left;
}
.extMenuCell,
.extMenuCellHdr {
width: 5%;
padding: 0;
}
.extMenuCell,
.extMenuCellHdr {
width: 5%;
padding: 0px;
}
.extMenuIcon {
z-index: 1;
position: absolute;
}
.tableDropMenuCell {
background-color: rgb(234, 243, 255);
cursor: pointer;
}
.tableDropMenuContainer {}
.tableDropMenuContainerContent {
min-height: auto;
min-width: 150px;
/* float: left; */
position: absolute;
background-color: white;
display: none;
}
.tableDropMenuContainerContent a {
display: block;
font-size: 14pt;
text-align: center;
border: 1px solid black;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="testTable">
<table class="panel unstriped">
<thead>
<tr>
<th class="extMenuCellHdr"></th>
<th class="main-action"></th>
</tr>
</thead>
<tbody class="scrollable-table">
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
<tr>
<td class="tableDropMenuCell extMenuCell">
<a href="#" class="tableDropMenuContainer">
<svg width="35" height="35">
<rect width="35" height="35" style="fill:rgb(0,0,255);stroke-width:10;stroke:rgb(0,0,0)" />
</svg>
<div class="tableDropMenuContainerContent">
<a href="">Option A</a>
<a href="">Option B</a>
</div>
</a>
</td>
</tr>
</tbody>
</table>
</div>
Someone please help me understand where i'm going wrong. :)