Search code examples
htmlcssinternet-explorerinternet-explorer-11

Internet Explorer (IE11) ignores CSS break-inside: avoid


in a two-column box (column-count: 2), the CSS setting break-inside: avoid should avoid some content to break from one column into the other. This works fine in Firefox and Chrome (using the appropriate -webkit... names), but not in Internet Explorer.

Here's an example: https://jsfiddle.net/6s7843ue/1/

Just to ensure that it's not the flexbox within the content: https://jsfiddle.net/6s7843ue/4/

I did not find any information the IE wouldn't support the break-inside, just the opposite: https://msdn.microsoft.com/de-de/library/hh772193%28v=vs.85%29.aspx

What am I doing wrong? Thanks!

Example code

(also see jsFiddle above)

HTML

<div class="outer" style="margin: 40px auto; width: 500px; border: 1px solid #0000FF">
    <div class="container">
      This is a rather long text to break into three separate lines, but sometimes won't stay in one column
    </div>    
    <div class="container">
      Should be in next column
    </div>
</div>

CSS

.outer {
    -moz-column-count: 2;
    -webkit-column-count: 2;
    column-count: 2;
    -webkit-column-gap: 1.6em;
    -moz-column-gap: 1.6em;
    column-gap: 1.6em;
}
.container {
  border: 1px solid #AAAAAA;
  margin: 0.2em 0;
  break-inside: avoid;
  page-break-inside: avoid;
  -webkit-column-break-inside: avoid;
  align-items: center;
}

Solution

  • Change in your container display: flex to display:inline-flex and it works in ie:

    .container {
      display: -webkit-inline-flex; /* Safari */
      display: inline-flex;
    }
    

    https://scotch.io/tutorials/a-visual-guide-to-css3-flexbox-properties