I noticed a slight difference after shrinking the viewport using a flexbox container-based layout. The following snippet contains several links inside two containers ( .container and .subcontainer ). In Chrome (45 beta), divs with the element class have the same width regardless of the size of the viewport. However, in Firefox (40), the width of each div changes depending on its content.
html, body { margin: 0; padding: 0; } .container { position: relative; display: flex; flex-direction: column; width: 50%; } .element { flex: 1 0 0; padding: 0.5em; text-align: center; position: relative; background-color: red; margin-right: 1em; } .subcontainer { flex: 0 1 auto; display: flex; } .element a { color: black; }
<!DOCTYPE html> <html> <body> <div class="container"> <div class="subcontainer"> <div class="element"><a>abc</a> </div> <div class="element"><a>abcdef</a> </div> <div class="element"><a>abcdef</a> </div> </div> </div> </body> </html>
I think that the "Run code snippet" functionality does not allow me to see this change, so I provide a couple of gifs showing the difference:
Chrome:

Firefox:

As you can see, the boxes are the same width in Chrome, but Firefox limits the first box very much, and the rest of the blocks keep their proportions. What is the reason for this discrepancy and how can I fix it? I would like to have the same width for each box. That was the purpose of using flex: 1 0 0 in the first place.
thanks
html css firefox google-chrome flexbox
Robert Smith
source share