Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Firefox/Gecko behavior is correct.</p> <p>WebKit is stretching up to 400px (the max-width) due to the header element's default "align-self: stretch" value. However, the spec is clear that "align-self: stretch" is <em>only</em> supposed to stretch if you have no auto margins in the cross axis. Quoting the spec:</p> <blockquote> <p>If a flex item has ‘align-self: stretch’, [...] and neither of its cross-axis margins are ‘auto’, the used outer cross size is the used cross size of its flex line, clamped according to the item's min and max cross size properties <a href="http://www.w3.org/TR/css3-flexbox/#cross-sizing" rel="nofollow">http://www.w3.org/TR/css3-flexbox/#cross-sizing</a></p> </blockquote> <p>The exception for "neither of its cross-axis margins are auto" is what Firefox is honoring here and WebKit/Blink appear to be ignoring.</p> <p>Now, to achieve your desired layout: It looks like you want both stretchiness <em>and</em> centering, and I don't think you can get both of those things simultaneously in the cross axis.</p> <p>You can get them simultaneously in the <em>main</em> axis of a flex container, though -- so you can fix this by adding a horizontal flex container around the header and the footer.</p> <p>I've done that here: <a href="http://jsfiddle.net/4Rv7K/16/" rel="nofollow">http://jsfiddle.net/4Rv7K/16/</a></p> <p>The relevant code (just with the 'header' for simplicity):</p> <pre><code>body { display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; } horizFlex { display: -webkit-flex; display: flex; } header { -webkit-flex: 1 0 auto; flex: 1 0 auto; max-width: 400px; height: 20px; background-color: yellow; margin: 0 auto; } [...] &lt;body&gt;&lt;horizFlex&gt;&lt;header&gt;Header&lt;/header&gt;&lt;/horizFlex&gt;&lt;/body&gt; </code></pre> <p>I think this achieves the layout you're looking for by wrapping the header and footer each in a horizontal flex container. The flex container stretches to the width of its parent (the body), and inside of it we have a single flex item (e.g. the ), which is flexible up to its max-width, and which we center (with auto margins) once it has reached its max-width. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload