Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get `page-break-inside: avoid` to work nicely with `flex-wrap: wrap`
    primarykey
    data
    text
    <p>I am trying to get <code>page-break-inside: avoid</code> to work in a form that uses a multi-line flexbox layout (with <code>flex-wrap: wrap</code>). The goal is simply to avoid breaking form questions when printing.</p> <p>This works well with a single line flexbox or without a flexbox. See the print preview of <a href="http://jsfiddle.net/MartijnR/nSE3P/1/show/" rel="noreferrer">http://jsfiddle.net/MartijnR/nSE3P/1/show/</a> (note the flexbox class is not applied)</p> <p>However, when using a multi-line flexbox, it seems to ignore the <code>page-break-inside: avoid</code> css rule. See the print preview of <a href="http://jsfiddle.net/MartijnR/nSE3P/2/show/" rel="noreferrer">http://jsfiddle.net/MartijnR/nSE3P/2/show/</a> (note I added the flexbox class to the section element)</p> <pre><code>&lt;form&gt; &lt;section class="flexbox"&gt; &lt;label class="flex-100"&gt; &lt;input type="text" /&gt; &lt;/label&gt; &lt;label class="flex-100"&gt; &lt;input type="text" /&gt; &lt;/label&gt; &lt;!-- etc --&gt; &lt;label class="flex-100"&gt; &lt;input type="text" /&gt; &lt;/label&gt; &lt;label class="flex-100"&gt; &lt;input type="text" /&gt; &lt;/label&gt; &lt;/section&gt; &lt;/form&gt; body, div, article, section, label { position: relative; } .flexbox { display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; -moz-flex-wrap: wrap; flex-wrap: wrap; -webkit-flex-direction: row; -ms-flex-direction: row; -moz-flex-direction: row; flex-direction: row; -webkit-flex: 100%; -ms-flex: 100%; flex: 100%; } label { display: block; margin: 10px 0; position: relative; } .flex-100 { min-height: 300px; border: 1px solid black; min-width: 80%; -webkit-flex: 100%; -ms-flex: 100%; flex: 100%; } input { display: block; } @media print { label { page-break-inside: avoid; -webkit-region-break-inside: avoid; } } </code></pre> <p>I've tried in both the latest Chrome and IE11 and both demonstrate the same behaviour which makes me think it's not a browser bug. (FF doesn't support multi-line flexboxes yet, so it won't work there until early next year)</p> <p>Does anybody know how to get <code>flex-wrap: wrap</code> flexbox layouts to play nicely with <code>page-break-inside:avoid</code>?</p> <p>PS. I'm aware that in the sample code it doesn't seem to make sense to use a multi-line flexbox, but in reality it does make sense for me to create a grid layout.</p>
    singulars
    1. This table or related slice is empty.
    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. 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