-
Notifications
You must be signed in to change notification settings - Fork 496
Chrome - Nested flex container - Flex item height using a percentage appears to be broken #84
Comments
After playing around with this more and reading some of the other issues, I tested without nesting any flex containers and the percentage height works fine. It's as soon as you nest you run into trouble. Maybe its flex-grow on the flex item/nested flex container? I see that other people are having similar issues. Updated jsfiddle. |
So I was using Updated jsfiddle |
Yeah, I think this is probably a Chrome bug. The height is definite, and thus a percentage should work. |
The same thing (percentage flex-base while flex-direction: column;) does not work in Opera. Though, it works fine in Firefox and IE. The workaround to make element occupy the remaining space is to set flex-grow: 1; (And forbid others to grow.) |
This is so fucked up... such an important issue that renders flexbox completely useless for Chrome. |
Is this still reproducible in Chrome? I made this Codepen that appears to work as expected? Unless I'm not following http://codepen.io/jpdevries/pen/MaGVKG?editors=110 |
@yairEO I understand it's frustrating when what you want to do doesn't work, but statements like this are neither true nor helpful. |
Is this either of these two Chrome bugs?
These are important issues, and right now the only workaround I have is using JS on window resize events. The issue 341310 has been open since Feb 2014 and one attempted fix had to be reverted. It is beyond belief. BTW: Have I missed where the two Chrome issues were described in the README.md ? |
This bug isn't in the README since no workaround has been identified as of yet. |
I noticed in another posting (forgotten where) someone 'solved' their flex problems using an intermediate Instead of asking for flex to understand height/width 100% on nested My nested Holy Grail example showing the problem.
vs.
Now I think I remember seeing you (@philipwalton) saying you thought support for pos:abs inside flex boxes would be changing in Chrome? Is this the kind of pos:abs usage you were referring too? I'm going to update my bug report to let the Chromium people know their suggested workaround didn't and that this pos:abs workaround does work. That might generate comments about Chrome and adding pos:abs div's willy-nilly? (See) Is this a workaround where we can add this flex bug to your lists? It does seem to work with FF, Edge, and IE11, as well as now Chrome. |
I got a "I guess that's okay" from the Chrome people. |
@jpdevries yes it's still broken in Chrome. That codepen is just a workaround. In the |
@tshinnic I reduced your test-case to make it a bit easier to follow. The absolute position trick is probably worth documenting. The only gotcha is it doesn't respect things like padding on the parent, but I suspect most people are familiar enough with absolute positioning to figure that out. |
FWIW, the CSSWG currently recommends avoiding using percentages at all on padding/margin: |
+1 |
Using this codepen: This seems to be fixed on Chrome 51 But not on Safari 9.1.1 |
I'm not sure if this could be considered a work around, but here is the codepen (from #84 (comment)) working in Safari had to set |
If anyone's interested, here is the bug on WebKit: https://bugs.webkit.org/show_bug.cgi?id=137730 It doesn't seem to be getting a lot of attention, even though it's a pretty serious issue for some layouts... Of course the workaround to make flex items flex containers works, but it's annoying. |
@benface And vitally, despite the title of this issue, it has nothing to do with nested flexboxes: it's purely about how percentages are resolved against the |
I second, that works:
Of course there is a downside: one can't have a row of elements with width in % inside .FlexItem. But I guess that is a rather uncommon scenario. |
https://bugs.webkit.org/show_bug.cgi?id=137730 has been marked as fixed. |
Still not fixed for Chrome in Linux, latest versions. Working like a charm in Firefox |
I think this jsfiddle demonstrating nesting flex column with percentage flex-basis not working. http://jsfiddle.net/o3s68nes/49/. Edge and firefox display as desired. |
I've reported a bug in chromium bugzilla https://bugs.chromium.org/p/chromium/issues/detail?id=872624 |
for reminding, assign any fixed height like
|
Chrome doesn't support percentage height values on flex items. It works fine in IE11 and MS Edge. I haven't tested any other browsers and I've not checked if percentage heights are part of the spec or not (sorry, maybe this is a non-issue).
Here is a jsfiddle.
Line 25 in the CSS is the issue. It works fine if I use pixels though.
The text was updated successfully, but these errors were encountered: