The inherit keyword specifies that a property should inherit its value from its parent element.
UPDATE:
First of all, sorry for misunderstanding,
You gave z-index: 2; to .content class. Its mean all .content elements have equal index. You can fix this and add another way. Go second row and add z-index: 3; then you will understand me. ๐
<div class="overflowTable">
<table>
<thead>
<tr>
<th class="headerTable">
Name
</th>
<td class="headerTable">
Status
</td>
<td class="headerTable">
People
</td>
<td class="headerTable">
Date
</td>
</tr>
</thead>
<tbody>
<tr>
<th class="content">
<div class="title">
<div class="name">
Name
</div>
<div class="moreOptions">
<span class="actualMenu">...</span>
<div class="menuMore"> Options<br/>
Options<br/>
Options<br/>
Options<br/>
Options<br/>
</div>
</div>
</div>
</th>
<td class="content">
Status
</td>
<td class="content">
First Person
</td>
<td class="content">
Random Date
</td>
</tr><tr>
<th class="content">
<div class="title">
<div class="name">
Name
</div>
<div class="moreOptions">
<span class="actualMenu">...</span>
<div class="menuMore"> Options<br/>
Options<br/>
Options<br/>
Options<br/>
</div>
</div>
</div>
</th>
<td class="content">
Status
</td>
<td class="content">
First Person
</td>
<td class="content">
Random Date
</td>
</tr>
</tbody>
</table>
</div>
Problem :
I have a very convoluted table in which I have to add a menu that appears on hover and has its position based on each row’s position.
Every row is generated at the same time in a loop (React props.map), so changing the next row z-index is possible, but I don’t know if I should.
I managed to do some work, but I can’t seem to make the menu appear on top of the “th” other than its parent.
I know it (probably) has to do with the Stacking Context, but I don’t know how to fix this.
I tried a lot of things, and some worked but then it broke something else. What I need is a way of maintaining the first column fixed and make this menu overlap all “th” siblings.
Things that worked but broke something else:
Taking the “sticky” position out of the “th”, the menu will overlap perfectly, but then it break the fixed first column.
Make the menu relative positioned, then it enters the normal flow, but that makes the div grow in and out.
Remove the “th” background-color property, but then it becomes invisible and, when the table is scrolled, you can see all the other columns underneath.
Thanks in advance!
PS: The original table is coded in React and SCSS, if this is of any help.
HTML & CSS: (the fiddle is written in scss because its easier to read)
<div class="overflowTable">
<table>
<thead>
<tr>
<th class="headerTable">
Name
</th>
<td class="headerTable">
Status
</td>
<td class="headerTable">
People
</td>
<td class="headerTable">
Date
</td>
</tr>
</thead>
<tbody>
<tr>
<th class="content">
<div class="title">
<div class="name">
Name
</div>
<div class="moreOptions">
<span class="actualMenu">...</span>
<div class="menuMore"> Options<br/>
Options<br/>
Options<br/>
Options<br/>
Options<br/>
</div>
</div>
</div>
</th>
<td class="content">
Status
</td>
<td class="content">
First Person
</td>
<td class="content">
Random Date
</td>
</tr><tr>
<th class="content">
<div class="title">
<div class="name">
Name
</div>
<div class="moreOptions">
<span class="actualMenu">...</span>
<div class="menuMore"> Options<br/>
Options<br/>
Options<br/>
Options<br/>
</div>
</div>
</div>
</th>
<td class="content">
Status
</td>
<td class="content">
First Person
</td>
<td class="content">
Random Date
</td>
</tr>
</tbody>
</table>
</div>
Comments
Comment posted by CausingUnderflowsEverywhere
The hover menu (moreOptions) seems to ignore all z index positioning unless we turn off absolute.
Comment posted by Rodolfo Rangel
Yes, if I take the “sticky” position out of the “th”, the menu overlaps perfectly, but then it breaks the fixed first column. And if I make the menu relative positioned, it enters the normal flow, but that makes the div grow in and out. So what I need is this div off the normal flow and the first column fixed. But I don’t know if it is possible.
Comment posted by Rodolfo Rangel
Thanks for reminding me, I tried that already, but what it does is set the background color to transparent so, while the menu becomes visible, so does every other column when you scroll right!
Comment posted by Rodolfo Rangel
Thank you for your reply! I forgot to mention that every row is generated at the same time in a loop (React props.map), so changing the next row z-index may be possible, but I don’t know how to do it recursively!
Comment posted by รmer Doฤan
Then try z-index : auto; instead of specific index ๐ and don’t forget vote me ๐
Comment posted by Rodolfo Rangel
Ok, I managed to solve the problem with your ideia, but I think there are better ways to do it still. I’ll vote your answer!