Alternative for page-break-inside: avoid
Why not, after the page is loaded with your content, use js to scroll through the content and add up the height of the div
s.
Once you've reached 1000px
or whatever you've determined to be the page height, then insert a blank div
styled with page-break-before
before the latest div.
Page-break-inside not working in firefox
MDN says that Firefox 19 is the earliest version to support the page-break-inside
property. Looks like you're out of luck.
https://developer.mozilla.org/en-US/docs/CSS/page-break-inside
Maybe you can find something useful from this question: alternative to page-break-inside:avoid because of compatibility issues
Cross-browser support of `page-break-inside: avoid;`
Webdevout.net is a great place to check browser CSS compatibility.
For page-break-inside
only IE8 and Opera 8+ are shown to support it
Print html div without breaking its contents between two pages
Your best bet is this (but has compatibility issues)
.noBreak { page-break-inside: avoid; }
Current compatibility (source):
Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
1.0 19.0 (19) 8.0 7.0 1.3 (312)
Other SO Discussion: alternative to page-break-inside:avoid because of compatibility issues
W3Schools
How to prevent column break within an element?
The correct way to do this is with the break-inside
CSS property:
.x li {
break-inside: avoid-column;
}
Unfortunately, as of October 2021, this is still not supported in Firefox but it is supported by every other major browser. With Chrome, I was able to use the above code, but I couldn't make anything work for Firefox (See Bug 549114).
The workaround you can do for Firefox if necessary is to wrap your non-breaking content in a table but that is a really, really terrible solution if you can avoid it.
UPDATE
According to the bug report mentioned above, Firefox 20+ supports page-break-inside: avoid
as a mechanism for avoiding column breaks inside an element but the below code snippet demonstrates it still not working with lists:
.x {
column-count: 3;
width: 30em;
}
.x ul {
margin: 0;
}
.x li {
-webkit-column-break-inside: avoid;
-moz-column-break-inside:avoid;
-moz-page-break-inside:avoid;
page-break-inside: avoid;
break-inside: avoid-column;
}
<div class='x'>
<ul>
<li>Number one, one, one, one, one</li>
<li>Number two, two, two, two, two, two, two, two, two, two, two, two</li>
<li>Number three</li>
</ul>
</div>
Related Topics
Hide Columns in a Table Using CSS
Why Is "-Fx-Background-Radius: 10;" Not Working
Overriding Body Background Color in Angular 7
Font Awesome 5 Pseudo-Class Not Working with My Kit
When I Float the Div to the Right the Screen Messes Up...I'Ve Tried Clear and Some Other Options
Can You Add a Non-Square Drop Shadow to Png Content with CSS
Why Does Container Div Insist on Being Slightly Larger Than Img or Svg Content
Animated .Gif VS Spritesheet + Js/Css
What's the Math Behind CSS's Background-Size:Cover
Padding Within Inputs Breaks Width 100%
How to Select the Element Prior to a Last Child
Css: Auto Height on Containing Div, 100% Height on Background Div Inside Containing Div
Vertically Aligning CSS :Before and :After Content
How to Use Helvetica Neue Condensed Bold in CSS