I have a multi-column div (2-4 columns depending on a setting in my app) generated live by user-provided markdown in a text editor. In some cases, they want to manually insert column breaks. To achieve this, I provide a Markdown snippet that generates a div with the CSS property break-after: column
to manually trigger column breaks. It works fine if it is set to display: block
. However, if the user then inserts a div that spans both columns (with CSS column-span: all
), that column-spanning element gets shunted to below its containing element, and any further text disappears entirely, as follows (in the latest version of Chrome, specifically):
.container {
column-count: 2;
height: 60mm;
border: solid black 1px;
}
.container .colbreak {
color: red;
break-after: column;
}
.container .wide {
color: blue;
column-span: all;
}
<div class="container">
<p>left left left</p>
<p>left left left</p>
<div class="colbreak">Column Break</div>
<p>right right right</p>
<p>right right right</p>
<p>right right right</p>
<p>right right right</p>
<p>right right right</p>
<div class="wide">
span all span all span all
span all span all span all
span all span
</div>
<p>more columns after</p>
<p>more columns after</p>
<p>more columns after</p>
<p>more columns after</p>
</div>
This is what it looks like (note the "more columns after" paragraphs are missing):
Changing the colbreak
to have display: inline-block
or otherwise just seems to ignore the break-after: column
altogether (perhaps this is the real question: Why is break-after
ignored for my inline-block element?:
As shown below, I get the same behavior by simply not including the colbreak
div at all:
Can anyone explain how to achieve the desired behavior? Since this is being rendered live as the user types it in, I would like to maintain the automatic balancing of columns by not requiring a separate div
for each column. Calculating text length and height and moving them between columns on the fly as it is typed seems more trouble than it's worth. This also stops working if the user changes to a setting with