-
Notifications
You must be signed in to change notification settings - Fork 498
Flex Items Grow too Wide with flex-direction:row #51
Comments
Here is a simplified pen that also shows the issue. View in Firefox/Edge vs Chrome/Safari to see the difference http://codepen.io/jpdevries/pen/mJROOL It's probably worth noting that the concept of the layout is the blue sidebar is fixed with the overflowing content on the right takes up the remaining space. If this is switched and the stage area uses a set width (like a percentage or something) the layout can be achieved cross browser, but that isn't an acceptable solution. |
Here is another pen with a kinda nasty work around. It uses a wrapper div around the |
Chrome Canary renders your second example the same as FF/Edge, which makes me think this is just Flexbug 1. Can you check and make sure? Also, fwiw, when you use bourbon in your demos its harder for me to figure out what's going on. |
@philipwalton thanks for having a look. I forked the second pen again and removed bourbon Without the vendor prefixes it won't work in certain browsers of course. I'm seeing what you mentioned, Canary is rendering that pen the same as FF/Edge 😲 I guess what I don't understand is how are you supposed to tell the In #42 which seems related the answer I came up with was to use |
Well, this is almost promising. I created another pen with yet another work around. This one uses a .stage-inner {
display:flex;
flex-direction:column;
flex-grow:1;
flex-shrink:1;
flex-basis:100%;
} seems to works in Canary, Chrome, Safari but not FF/Edge. Theres a |
I use autoprefixer on all the Flexbug demos. It allows you to write valid CSS, and it adds all the necessary prefixes behind the scenes.
If you give the parent an explicit width or max-width, it will not grow larger than that. I don't think there's an actual bug here that's not already documented in the README. If I've missed something, feel free to comment or reopen. |
@philipwalton I feel this should be re-opened or discussed further. I'm also not sure which section of the README you feel covers this issue. Did you see what I mentioned above?
Isn't the whole point of flexbox to not have manually calculate widths? By the very nature of flexbox you may not know what size it will wind up. The reason this layout is breaking is a flex item, who is also a flex parent, is growing larger than it should be able to. I've tried my best to understand the flexbox spec, and maybe I am misunderstanding something but are you implying that there is no way to overflow content within nested flex boxes without manually setting width constraints? If so, is that a breaking change from Flexbox 1? |
@jpdevries I'm honestly not sure what exactly you're reporting in this issue. If your question is just "how do I get this to work cross browser?" then Stack Overflow is probably a better place to ask. If you're reporting a bug, you should vastly simplify your example, so it can be clearly demonstrated what's not working. Your examples are very involved, and you're doing a lot of strange things with them like using tables but changing their display values to flex. Every level of complexity you add makes it harder for someone else to figure out what's wrong, and it makes it more likely that the problem is really a combination of several factors rather than one specific issue. The purpose of this repository is to provide people with workarounds to common flexbox bugs, but if we can't isolate exactly what's going on, it's impossible to describe it and warn other people about it. |
@philipwalton I posted a simplified example that uses divs instead of tables the same day I opened this issue. I also just updated that pen to use autoprefixer so it is more legible. I think the simplest way to describe the issue would be that a flex item is being allowed to grow infinitely and therefore does not overflow it's own inner content as intended.
I've posted several work arounds and spent a lot of time debugging these issues and done my best to document them. If you feel I've misused this repository I apologize. |
Thanks you. Simplified examples are much easier to reason about.
No, not necessarily. In both models the parent and children can affect each other. Here's how you can do what you want: |
Dude, you're a magician! Even works in Edge. It looks like having Thank you so much! This is great 💯 Just For the recordIn Firefox Gecko (39) I noticed that simply adding Prior to your helpful response and solution I read the spec and found these sections may be relevant to this discussion:
This both implies that nesting should work (so I'm not sure it breaks with
This implies that single-line flex containers overflow.
The distributes free space to its items verbiage seems to imply that a group of flex items should not be able to make it's container grow, especially if it's container is also a flex item.
The |
Top: Safari (correct) Bottom: Firefox (incorrect)
So in this codepen we have a flex parent (
.eureka
) with two children.pathbrowser
(blue) and .stage
(green).The
.stage
is also a flex parent that usesflex-direction:column
to lay it's two children (.topbar
and.eureka-table
) out vertically.The
.eureka-table
contains a basic table that a has atbody
that usesoverflow-x:auto
for scrollbars with a bunch of content in it.The concept of the layout is the blue sidebar on the left takes up a fixed amount of space while the stage takes up the rest. The stage should be able to overflow content without breaking the layout.
Currently In Firefox 38 and Edge nightly the content does not overflow correctly and the layout breaks.
This codepen forks the above codepen and makes one change (line 34) that sets
.eureka {flex-direction:column}
. This will make the blue sidebar layout incorrectly but notice the table content now overflows correctly.Also see #42
The text was updated successfully, but these errors were encountered: