question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Width calculation and overflow errors with flexbox in Firefox - IE - Opera

See original GitHub issue

Hi,

I’ve managed to identify an issue that happens when a slick carousel is initialized inside a flex item (child of a display: flex container, with flex: 1 auto).

It’s quite hard to describe what happens, basically, instead of being limited by width constraints of parent elements (e.g. the width of the body), the carousel forces the flex item to stretch indefinitely, thus stretching its parent with it.

Noticed that the .slick-track is assigned a huge width, which is only recalculated as a higher value every time the window resizes (and probably slick reinitializes).

Also, the .slick-list, which in Chrome/Safari respects the overflow: hidden rule and only stretches as far as is allowed by its container, in Firefox / IE / Opera it expands as far as the .slick-track.

Can confirm that forcing max-width: 100% on the flex item limits its width to that of its parent, but it does not take into account the other children of the flex container.

Reproduced here: http://jsfiddle.net/uLqt4zmy/1/ Also attaching an attempt to limit the width in a typical flexbox usage pattern - reproducing the holy grail layout using a flexing and a non-flexing child: http://jsfiddle.net/uLqt4zmy/9/

Reproduced in Firefox 35 on OSX and Firefox 35 / IE 11 / Opera ?? on Windows.

Any idea what could be causing this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

24reactions
tibineagucommented, Mar 31, 2015

Apparently this is caused by how the flex-items are supposed to behave, and Chrome is actually the one implementing the W3C spec wrongly.

This article will shed some more light on it: https://bugzilla.mozilla.org/show_bug.cgi?id=1108514

The solution is to add min-width: 0px; on the flex children and their expansion will be restricted to the overall layout. (no idea why that happens tho)

4reactions
fredeccommented, Jun 15, 2019

2 days struggling with this problem. Just min-width: 0px; - Thank God!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flex containers should use "flex-basis" instead of "width" for ...
I would like to add one more test case. From it you can see, that 0px flex-basis is ignored, if flex item has...
Read more >
Mastering wrapping of flex items - CSS: Cascading Style Sheets
This means that if you have a set of flex items that are too wide for their container, they will overflow it. If...
Read more >
flex-basis - CSS: Cascading Style Sheets - MDN Web Docs
The flex-basis CSS property sets the initial main size of a flex item. ... The Firefox Flexbox Inspector showing the size of the...
Read more >
flex-shrink - CSS: Cascading Style Sheets - MDN Web Docs
The flex-shrink CSS property sets the flex shrink factor of a flex item. If the size of all flex items is larger than...
Read more >
flex-wrap - CSS: Cascading Style Sheets - MDN Web Docs
The flex items are laid out in a single line which may cause the flex container to overflow. The cross-start is either equivalent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found