Re: Fixed table layout and how it affects ancestor widths

"Tab Atkins Jr." <> writes:

> On Mon, Jun 14, 2010 at 5:59 AM, Morten Stenshorne <> wrote:

>> Testcase:
>>    <!DOCTYPE html>
>>    <html>
>>      <body>
>>        <p>There should be no scrollbar</p>
>>        <div style="display:table; width:1px;">
>>          <div style="display:table; table-layout:fixed; width:100%;">
>>            <div style="overflow:hidden;">
>>              <div style="width:4000px; height:20px;"></div>
>>            </div>
>>          </div>
>>        </div>
>>      </body>
>>    </html>
>> [...]
>> 1. Is Opera right in letting content C inside a fixed-layout table B
>> affect a shrink-to-fit container or auto-layout table-cell A ancestor
>> of B?
> I don't think so.  It produces a reverse constraint that I don't think
> is expressed anywhere in CSS.

It's no more reverse than any other shrink-to-fit situation.

What's the difference between:

  <div id="elm" style="float:left;">
    <div style="width:100%; display:table; table-layout:fixed;">
      <div style="width:700px; height:100px;"></div>


  <div id="elm" style="float:left;">
    <div style="width:100%;">
      <div style="width:700px; height:100px;"></div>


I find it strange if 'elm' in the first case should be 0 and 700px in
the second. CSS doesn't define exactly how to treat percentages inside
of a shrink-to-fit (or auto-layout table), but all browsers have
landed on treating percentages as auto as far as propagating width
requirements to a shrink-to-fit (or auto-layout table) ancestor is

> In this specific case, CSS seems pretty clear about how the layout
> should work in  Fixed table layouts never depend on the
> contents of the cells, but only on the width of the table, the
> columns, and the actual cells of the first row.

Yes, the width of auto-layout tables is directly affected by their
content. Not so for fixed-layout tables. Also not so for regular
blocks. That's how I read the spec.

> In the particular testcase you provided, the fixed table should be
> 1px wide (100% of its parent),

The parent is an auto-layout table. Its 1px width will be overridden
by its MCW; quoting the spec: "the formatted content may span any
number of lines but may not overflow the cell box" - setting the width
to 1px would overflow the cell box.

---- Morten Stenshorne, developer, Opera Software ASA ----
---- Office: +47 24164206 ---- Cellular: +47 93440112 ----
------------------ -----------------

Received on Tuesday, 15 June 2010 06:38:27 UTC