I have a page which generates coupons. Each coupon is a div
with a height varying depending on the content. I want to print as many coupons on each page as possible, but I do not want the coupons to be split out over several pages. The CSS property page-break-inside
does exactly what I need. However, I need this to work for Firefox and/or Chrome. And this is not supported. Two years and one year ago the same question was asked, and there was no good alternative for this. We are a lot of CSS3/HTML5/overall browser development further... is there an alternative to get this working?
Example is here: http://jsfiddle.net/e3U66/2/
Assume that a page, when printed, measures 1000px. I want the second DIV to appear on the second page, because otherwise it is split out over the first and second. This code works in Opera, but not in FF or Chrome.
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.