-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-tables] How does table-layout:fixed even work? #121
Comments
Pinging @atotic - fix one bug in tables, deal with tables the rest of your life. |
In Gecko, we used fixed layout when all of the following conditions (see nsTableFrame::IsAutoLayout) hold:
Fixed-layout tables report an intrinsic max-content inline size as infinite. The intrinsic min-content inline size is computed by adding, for each column:
The actual column size calculations in final layout are similar, except that there's a percent distribution and balancing pass. Columns either have a length width, a percent width, or no width, based on the same rules used above for min-content width computation, except without the bogus attempts to subtract off cell-spacing for percentage widths. Note that, again, we use the colspan-adjusted share of cells in the first row for each column, which doesn't really make sense if some of those columns have other specified widths. If you want me to try to write out this algorithm in more detail, let me know. Then, if that assignment takes up too much space, reduce the width of any percentage-width columns proportionally to their percentage, but not below zero. Then, if there is extra space:
|
Thanks @dbaron! I think I can manage from here. I still have a question about this behavior: Based on my knowledge of css and your intrinsic min-content inline size computation algorithm, /3/ looks really strange to me. It looks consistent across browsers though which makes me wonder how... |
Isn't that just the intrinsic max-content inline size being infinite? I don't see how intrinsic min-content inline sizes are involved in that test. |
I thought by default "float:left" used min-content sizing, that's why |
No, it does fit-content, as described in https://drafts.csswg.org/css-sizing-3/#valdef-width-fit-content |
Oh, that makes sense. Otherwise we would wrap at every word, or so. Thank you for clarifying. Still found another strange case when combined with flex for this one (still reasonable in Firefox and Edge, not much so in Chrome): Do you think we should make Firefox/Edge behavior per spec? How would we achieve that? If max-content was really infinite, the table should accept to grow; shouldn't it? |
The |
Hi there. I am not sure I understand how fixed table-layout works in some edge cases (and given the docs I can find online I am not the only one).
TLDR: The ask is for browser vendors to have a look at how
table-layout:fixed
works in their browser. Particular attention is needed for these cases:width:auto
;width:min-content
;width:max-content
;float:left
;position:absolute
; when the sum of column widths overflow the table width; when some columns do not have a<td>
or<th>
in the first row, but are required by later<tr>...<td>
; I am interested in all behavior involvingtable-layout:fixed
at this point.So, lets start by one definition that clearly does not match implementation:
According to MSDN:
Then how do we explain this test case:
I think the reason is that no browser apply the 10.3.3 algorithm when the width of the table is auto, and therefore use normal layout (initially I thought Firefox also did an exception if the width of the cells of the first row is explicit (example /3/ here), but it looks like to be a difference in the general sizing algorithm instead).
Closer definitions
According to MDN:
According to CSS 2.1:
Remaining questions
Now, what to do when the width of the table depends on the content is another question. Firefox ignores the fixed algorithm as if the width was auto for max-content, set width:0 for min-content. Chrome set width:0 for both cases (Edge does not support those):
The final bit that was left undefined was how other columns that are not in the first row are rendered.
It looks like they are with width set to 0 in all browsers:
Call for action
I'm going to check whether all the previous assumptions holds true in EdgeHTML, but I would like other browser vendors to chime in in this case to assert there is no other special case where they apply the fixed algorithm anyway. Nobody seemed to apply it when floated or absolutely positioned (should behave like width:min-content), though in the latter case browsers didn't agree on the 100% table width.
Cc: @dbaron + @tabatkins ?
The text was updated successfully, but these errors were encountered: