I got this problem while using Bootstrap and I had multiple columns in each rows.
I was trying to give page-break-inside: avoid;
or break-inside: avoid;
to the col-md-6
div elements. That was not working.
I took a hint from the answers given above by DOK that floating elements do not work well with page-break-inside: avoid;
.
Instead, I had to give page-break-inside: avoid;
or break-inside: avoid;
to the <div class="row">
element. And I had multiple rows in my print page.
That is, each row only had 2 columns in it. And they always fit horizontally and do not wrap on a new line.
In another example case, if you want 4 columns in each row, then use col-md-3
.