Background color is overwriting border-color on sticky TH element
Categories
(Core :: Layout: Tables, defect)
Tracking
()
People
(Reporter: rene.hellenes, Unassigned)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0
Steps to reproduce:
Create a table with a side scroll. in TBody: First cell in a row should be a TH. Give it position sticky, border (eg. gray solid 2px) and a background-color.
The issue is shown in the attached screenshot with most of the settings needed to reproduce
Actual results:
When the background color is added, the border-color disappears. It looks like the border is there, just not visible. It gets visible if you either turn off position sticky or make it a block element.
Expected results:
The desired result is that the border would appear as it does on other elements.
The desired result is achieved in chrome, edge and safari.
Updated•3 years ago
|
Comment 1•3 years ago
|
||
Rene, thanks for the report. Could you possibly provide a simplified testcase that demonstrates the issue? It wasn't entirely clear to me exactly how to set things up.... if you can attach an example HTML file here, or a link to a codepen or similar example, that would be really helpful. Thanks!
| Reporter | ||
Comment 2•3 years ago
|
||
Sorry for the delayed response. Here you go: a codepen with simplified code
The red border-bottom should go underneath the <th> inside the <tbody> aswell.
Comment 3•3 years ago
|
||
Thanks! So the issue here isn't specific to position:sticky; a similar problem can be reproduced with other properties.
It seems to be the use of a property that causes the th cells to become a new stacking context (like position:sticky) combined with border-collapse:collapse rendering, which results in the borders being painted by the underlying table and then getting obscured by the backgrounds painted by the cells.
A similar problem can be triggered by other properties such as transform or opacity, that also make the cell into a new stacking context. A further-reduced version of the testcase: https://codepen.io/jfkthame/pen/OJoZjZL. I've made the background of the th elements partially opaque here, to highlight how the borders are being painted behind it.
I think what's needed to fix this is to inset the background by half of the border width when border-collapse is in effect, so that they don't overlap.
Updated•3 years ago
|
Comment 4•2 months ago
|
||
This no longer reproduces. The codepen from comment 2 (border-collapse table, tbody th { position: sticky; background: lightgrey; border-bottom: 3px solid red }) shows the border missing under the sticky th on the Firefox 111.0 release and painted across the full row on Firefox 158.0a1 (local Linux build, headless screenshots attached, DPR 1 and 2). A contrast page trying position: static/relative, transform, opacity, isolation, will-change, no th background, 1/2/3px borders and border-collapse: separate is green on 158 in every row.
Updated•2 months ago
|
Description
•