Fixed table header broken when cells have "position: relative" content
See original GitHub issueWhen cell content uses position: relative
, its painted on top of the fixed header.
For example, when the sample table looks like this:
<virtual-scroller #scroll
[items]="filteredList">
<table>
<thead #header>
<th>Index</th>
<th>Name</th>
<th>Gender</th>
<th>Age</th>
<th>Address</th>
</thead>
<tbody #container>
<tr *ngFor="let item of scroll.viewPortItems">
<td><div style="position: relative; color: red; font-weight: bold">{{item.index}}</div></td>
<td><div style="position: relative; color: red; font-weight: bold">{{item.name}}</div></td>
<td><div style="position: relative; color: red; font-weight: bold">{{item.gender}}</div></td>
<td><div style="position: relative; color: red; font-weight: bold">{{item.age}}</div></td>
<td><div style="position: relative; color: red; font-weight: bold">{{item.address}}</div></td>
</tr>
</tbody>
</table>
</virtual-scroller>
… then it’s rendered like:
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10
Top Results From Across the Web
Fixed table header broken when cells have "position: relative" content
When cell content uses position: relative , its painted on top of the fixed header. For example, when the sample table looks like...
Read more >css - HTML Table Header with Fixed Position and scroll able ...
This will work if you don't have an horizontal scroll. ... text-transform: capitalize; position: relative; padding: 10px 25px 10px 25px; ...
Read more >Position Sticky and Table Headers | CSS-Tricks
The issue boils down to the fact that stickiness requires position: relative to work and that doesn't apply to <thead> and <tr> in...
Read more ><table>: The Table element - HTML - MDN Web Docs - Mozilla
This attribute defines the space between the content of a cell and its border, displayed or not. If the cellpadding's length is defined...
Read more >Fixed Table Headers - Adrian Roselli
The different z-index values help ensure your column headers sit in front of your row headers. Otherwise the visible row header will look...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m still trying to validate this in other browsers, but it seems like swapping the thead and the tbody in the HTML fixes this issue.
The problem is still in version 4.0.3.
But does work with the suggestion by @natelokers.