I have a bunch of paragraphs on a page:
<p> ... </p> <p> ... </p> <p> ... </p>
The CSS rule for those paragraphs is:
p { margin: 20px 0; page-break-inside: avoid; }
Live demo: http://jsfiddle.net/KE9je/2/show/
If I understand the page-break-inside
property correctly, the above should ensure that no paragraph is split between two pages. (A paragraph is either displayed on the "current" page, or if it doesn't fit completely, it's moved to the next page.)
This doesn't seem to work in Chrome. Open the demo, right-click the page, choose "Print...". You'll see a print preview - the fifth paragraph is split between page 1 and 2.
What am I doing wrong? How can I make this work in Chrome?
The page-break-inside property in CSS is used to specify how the page breaks inside the element to which it is applied while printing. It inserts a page break or sometimes it used to avoid page break inside an element while printing. Property Values: auto: It is the default value.
To fix this just change it to page-break-after:auto. It will break correctly and not create an extra blank page.
To suggest a page break, add <P style="page-break-before: always"> before the beginning of a new printed page. For example, if you place the following tags on a HTML page and print it using a compatible browser, you will end-up with three pages with the sample text.
Actually, it DOES work in Chrome, and the solution is really silly!!
Both the parent and the element onto which you want to control page-breaking must be declared as:
position: relative;
Check out this fiddle (or in fullscreen)
This is true for:
page-break-before page-break-after page-break-inside
However, controlling page-break-inside
in Safari does not work (in 5.1.7, at least)
I hope this helps!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With