W3C home > Mailing lists > Public > www-style@w3.org > April 2013

[css-flexbox] min-width/height: min-content defaults for replaced items and overflow containers

From: Elliott Sprehn <esprehn@gmail.com>
Date: Mon, 22 Apr 2013 16:50:59 -0700
Message-ID: <CAPJYB1iSfhfT_Lwbwa-h27LaHAE1CYZiSHQA6BXy8+mJnSF-Yg@mail.gmail.com>
To: www-style list <www-style@w3.org>, fantasai <fantasai@inkedblade.net>, "Tab Atkins Jr." <jackalmage@gmail.com>, Ojan Vafai <ojan@chromium.org>
Recently the spec for flexbox was changed so that the min-width of flex
items was no longer min-content (mutatis mutandis for height), but this
produces some bad behavior when using replaced things like <button> or
<img> as flex items. Previously they had an implicit min-width: min-content
which would prevent them from becoming smaller, but now they'll end up
being crushed.


<div style="display: flex;">
  <img width="200" height="200">
  <p>some long text that should wrap here</p>

In this example the <img> can end up being considerably less than 200px
wide which isn't what the author intended.

Before this change was made to the spec the min-width was min-content which
worked fine for this but had other bad behavior like making overflow:
scroll on a flex item behave unexpectedly since the item would expand out
to the min-content size.


<div style="display: flex; height: 100%;">
  <div style="overflow: scroll;">
     ... thousand 100px tall items ...

The overflow: scroll <div> would end up being as tall as it's min-content
size which is the height of all the items and you wouldn't get a scrollbar.
Instead you needed to use min-height: 0 on the <div> to get your scrollbar
to work.

Both of these have proven to be surprising behavior, instead I think we
should combine the behavior so the min-width is min-content unless your
overflow property computes to a value other than visible in which case it
should be 0.

This special cased behavior gives a sensible result for <img> and overflow:
scroll as flex items.

- E
Received on Monday, 22 April 2013 23:52:06 UTC

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