-
Notifications
You must be signed in to change notification settings - Fork 22.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content suggestion: Caveats to Flex & Grid #6132
Comments
I've actually got a big list of this sort of stuff, so could write something up. I think it's really centered around the different ways things behave when not in normal flow. Thanks for the suggestion @indrora |
A lot of it comes down to "CSS2 had a lot of defaults... Then CSS3 quietly changed those defaults but left everything quirks-compatibly default for the old stuff" and now that new things (grid, flex, etc) are being added to the living standard, a lot of the old standby defaults are not longer what folks expect. I am curious how many 'css resets' also add unknown gotchas to the standards that people don't know about... |
It's really that what you might expect in normal flow is different once you are in a flex or grid formatting context. The reality is that a lot of stuff has been cleaned up and clarified in recent years, however a core tenet of designing CSS is that we don't break the web, so it has to be done in a way that protects legacy sites from suddenly breaking. |
Btw the code has a bug:
Not really. The container is getting limited at 50em (800px) due to This is the issue of overflow. The issue is the |
What is the new suggestion?
A section that outlines caveats about using Flex and Grid, such as
::before
and::after
pseudo-elementsmin-width
andmax-width
"not working" because of assumed valuesWhy is it important or useful?
I spent a week and a half hunting down why my flex-based two-column layout behaved "wrong" and why a loose
pre
tag was sending my layout into the middle of nowhere.One or two pages that covers the specific caveats and changes to the CSS model when using
display: flex
ordisplay:grid
would help with this. There's some real zingers that I've discovered that aren't well documented at the moment.The issue comes down to a simple line in the CSS level 3 spec about widths and
auto
:oh no. What's it say for flex? Let's ask the flex spec, section 9.9.1:
Oh no.
This means that
min-width: auto
will causemax-width: <value>
to be ignored, plus hard width values withinflex
containers to be outright ignored.pre
is always a box context (it has to be, since it's handling preformatted text not to be mucked with by the UA) and will cause the min-width of the flex box even when scrollbars are asked for to be the minimum width of the longest line of text.A simple codepen of the issue can be seen here: https://codepen.io/indrora/pen/KKWEYEj
Setting the rule
.container main { min-width: 0; }
will cause the content to flow as is expected.Here's some people and some spec stuff:
auto
The text was updated successfully, but these errors were encountered: