W3C home > Mailing lists > Public > www-style@w3.org > March 2016

Re: [css-box] shrink-to-fit and floats

From: Pavel Panchekha <me@pavpanchekha.com>
Date: Tue, 08 Mar 2016 00:42:17 +0000
Message-ID: <CAE4=OQ_6L+URxriHrXwXKc5c8rS3hfUwF8iDDaoXz16Dv6MFbg@mail.gmail.com>
Cc: www-style list <www-style@w3.org>
To: "Tab Atkins Jr. " <jackalmage@gmail.com>
Thank you, Tab.

> ​To make sure we're on the same page, here's the markup:

Yes, we agree on the markup, and the window size can be 500px.

I understand the preferred width, available width, minimum preferred width
formula used to compute shrink-to-fit width; I am only confused about how
we compute the width of the div, for the purposes of determining the
preferred
width of the section.

> ​If the div had "margin-right: -10px", all the above still applies, but
> the calculation of the minimum width that doesn't trigger overflow
> changes.  Overflow happens when the *margin box* of an element is
> wider than its container, and in this case the margin box is 0px wide
> - 10px from width, minus 10px from margin-right.

​Am I taking you correctly, then, that margins are treated differently
when determining shrink-to-fit and ordinary width, namely that ​right
margins are not ignored for computing shrink-to-fit width yet are
ignored for computing ordinary width (in situations where that's
applicable)?

​Every other part of the layout for this example you and I agree on.​

​I suppose I can reduce my confusion now to this question:
when is the margin-right ignored, and when is it not?

It sounds like margin-right is ignored during the layout of block-level,
non-replaced elements in flow, when computing their actual layout,
but it is not ignored when computing their width for the purposes of
determining the preferred [minimum] width of a container.

> Sizing spec does correct this lack and define things more precisely.

That's a useful draft to be aware of, thank you. I think the relevant
sentence of that specification would be this one, in §4.3:

> Otherwise, if the computed inline-size of the block is fit-content, auto,
> or fill, its min-content inline-size contribution is its min-content
> inline size plus any inline-axis margin, border, and padding.

Is this referring to the inline-axis (that is, the left & right) *used*
values
for margin, border, and padding or the *computed* values?

The used values are the ones computed by ignoring the specified
margin-right, while the computed values would be the expected ones.
It may be best to amend that draft to make the choice here clearer.

—Pavel Panchekha
Received on Tuesday, 15 March 2016 14:14:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:01 UTC