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

Re: [css3-flexbox] flex-basis initial value should be 0px

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Wed, 23 May 2012 11:23:01 -0700
Message-ID: <CAAWBYDCmQNvbnKkNMrCwsM5-zO+7=fifWSW3LOB8u-yn7TO1dg@mail.gmail.com>
To: Tony Chang <tony@chromium.org>
Cc: fantasai <fantasai.lists@inkedblade.net>, www-style@w3.org
On Wed, May 23, 2012 at 11:04 AM, Tony Chang <tony@chromium.org> wrote:
>> Ojan, Tony, when you say that 'flex-basis:0' is cheaper than 'auto',
>> are you keeping in mind that, by default, flexbox items will have a
>> min-width/height value of 'min-content'?  I don't know if we
>> fast-track that for width, but it seems to require at least *some*
>> layout-level computation.  For column flexboxes, the min-height seems
>> to require a full layout anyway.
>
> Huh, I totally missed section 4.4 about the implied min size.  I see it now
> in the minutes sent on May 15th.
>
> I understand the desire to avoid overflow, but it has the cost of making
> layout slower by default, even if there's no overflow.  I'm not sure it's
> worth it.  I would rather authors have to opt-in for slower behavior to
> avoid overflow by setting min-width to min-content explicitly.  That seems
> more consistent with how min-width works everywhere except for tables.
>  Also, I think one of the reasons people don't use table layouts much
> anymore is because of slow cases like this.

:/ The problem with making the default behavior bad in corner cases is
that people generally won't flip switches they don't have to, so when
the corner case comes up, most people will end up with bad behavior.

You can definitely opt into the "shut up, I know what I'm doing, 0 min
size" by setting "min-width: 0;" explicitly.  I generally prefer
making the default behavior safe-but-slightly-slower and giving people
the option to flip a "speed it up" switch that's slightly more
dangerous.


> As a web author, if I'm trying to do a grid line layout using flexbox, I
> think I would want to overflow rather than mess up the grid.  For example,
> if I had a header align to a grid and I wanted the footer to align to the
> same grid using a different flexbox, I would want to overflow.  Maybe this
> is just an argument for using grid layout, but I think that's more
> complicated and overkill for many sites.

Note that the grid only gets "messed up" if the screen is small enough
to make some of the items less than their min-size.  min-size only has
an effect when an item tries to shrink below it; during normal flexing
it has no effect.


>> On Wed, May 23, 2012 at 1:48 AM, Anton Prowse <prowse@moonhenge.net>
>> wrote:
>> >> On the other hand, they merely *seem* indistinguishable for another
>> >> common case, where each of the items has a short amount of text. On a
>> >> large screen, they may seem approximately equal in both situations,
>> >> but on a small screen, the "flex: auto" behavior is better, since it
>> >> won't cause overflow on any of them until absolutely necessary.
>> >
>> > For navigation menus, the property you describe is very important, even
>> > when the difference between the natural sizes of the items is not
>> > enormous.
>
> I'm OK with navigation menus having to add min-width: min-content to avoid
> overflow (or using flex: auto).  Basically, you're opting into the slow
> layout, but a navigation menu is simple and the slower layout is OK.
>
> The benefit is when trying to use flexbox for site layout (like 3 column),
> you get fast behavior by default.  Having to compute the min-content size of
> the main body is going to be slow.

That's true. :/

~TJ
Received on Wednesday, 23 May 2012 18:23:52 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:54 GMT