Consider the following HTML:
<div class='x'>
<ul>
<li>Number one</li>
<li>Number two</li>
<li>Number three</li>
<li>Number four is a bit longer</li>
<li>Number five</li>
</ul>
</div>
and the following CSS:
.x {
-moz-column-count: 3;
column-count: 3;
width: 30em;
}
As it stands, Firefox currently renders this similarly to the following:
• Number one • Number three bit longer
• Number two • Number four is a • Number five
Notice that the fourth item was split between the second and third column. How do I prevent that?
The desired rendering might look something more like:
• Number one • Number four is a
• Number two bit longer
• Number three • Number five
or
• Number one • Number three • Number five
• Number two • Number four is a
bit longer
Edit: The width is only specified to demonstrate the unwanted rendering. In the real case, of course there is no fixed width.
I had the same problem i think and found a solution in this:
Working also in FF 38.0.5: http://jsfiddle.net/rkzj8qnv/
I just fixed some
div
s that were splitting onto the next column by addingto the child
div
s.*Realized it only fixes it in Firefox!
I made an update of the actual answer.
This seems to be working on firefox and chrome: http://jsfiddle.net/gatsbimantico/QJeB7/1/embedded/result/
Note: The float property seems to be the one making the block behaviour.
The following code works to prevent column breaks inside elements: