W3C home > Mailing lists > Public > www-style@w3.org > February 2012

RE: [css3-flexbox] when are margins on flexbox-items computed & subtracted from available space?

From: Alex Mogilevsky <alexmog@microsoft.com>
Date: Thu, 16 Feb 2012 14:42:03 +0000
To: Daniel Holbert <dholbert@mozilla.com>, Tab Atkins Jr. <jackalmage@gmail.com>, "www-style@w3.org list" <www-style@w3.org>
Message-ID: <D51C9E849DDD0D4EA38C2E539856928412E5C9D2@TK5EX14MBXC214.redmond.corp.microsoft.com>
> From: Daniel Holbert [mailto:dholbert@mozilla.com]
> Sent: Wednesday, February 15, 2012 3:02 PM
> First Clarification:
> ====================
> Before we resolve flexible widths, we clearly need to subtract flexbox items'
> margins (assuming we've obtained exact px values for them), but I don't think
> the current spec accounts for this.

All flexbox algorithms deal with margin boxes. If it is not made clear in the algorithm, it may need to say somewhere that margins, border and padding are added to the preferred size.

> This would probably need to be prepended as an additional step at the beginning
> of the "Resolve the Flexible Lengths" algorithm in the current ED.[1]
> Possible spec text:
> {{
>   1. For each item on this flexbox line, subtract the resolved values of its margin
> properties in the main axis from the available space.
> }}
> (not sure if "resolved" is the correct word there -- I mean "after percentages
> have been converted to px".  We also may need to add some special-cases,
> depending on how auto margins end up being handled.)

It could be defined that way too (with no change in results). I find it easier to deal with margin boxes though...

> Second Clarification:
> =====================
> I'd like to clarify the behavior of percentage margins on flexbox-items.
> The CSS2.1 Box Model says that percentage values for margin-* are calculated
> w.r.t. the "width of the containing block"[2].
> I assume the flexbox fills the role of "containing block" here, and so these
> margins would always be resolved w.r.t. the flexbox's _width_ (even for margin-
> top/bottom in a vertical flexbox).  Is that correct?


> Also, in cases where the flexbox's width is affected by these margin-values, are
> we defining the behavior of percent-valued-margins on flexbox items, or leaving
> it undefined?  (CSS 2.1 explicitly leaves this undefined for the box model -- but it
> seems like it'd be nice to minimize the number of undefined things in a brand-
> new layout model, when possible.)

Need to check with implementation. I am pretty sure percent from 'auto' is zero.

Received on Thursday, 16 February 2012 14:42:46 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:12 UTC