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.
Below a solution made with the help of Prototype (1.7) library
Maybe it helps
Honestly I would just advise creating images of the actually coupons or generating a pdf. I'm assuming you are probably generating barcodes for all the coupons already, so generating the actually images shouldn't be to hard using php (or whatever the code choice might be).
Here is some info on php image creation, but SO would probably be a better source for examples.
http://php.net/manual/en/function.imagecreate.php
Then you could just list the images.
There's no sense it recreating the wheel.
set float left for these div and set width as 100%. i wont tryed it ., it's may work.
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 blankdiv
styled withpage-break-before
before the latest div.