I have a bit of logic in one of my Rails views that states if the table
I'm about to print is over 7 rows, create a div
around the table
with a min-height
style to make sure the footer below this table
goes to the end of the page 2, rather than page 1.
I've tested this logic in many browsers including: Chrome, Safari and IE (!) and they all work as expected. Firefox, however, is adding a pesky page-break right before the div
and table
. I have tried avoiding this page-break by adding this CSS style in the div
and also in the table
: page-break-before: avoid;
as well as this newer Firefox style: break-before: avoid;
, but it doesn't seem to affect this page-break during printing. Any other ideas? Does Firefox automagically add a page-break before large divs when printing?
<div style='min-height: 1150px;'>
<table>
blah blah table stuff...
</table>
</div>
Syntax: page-break-inside: auto; avoid: It avoids a page break inside the element.
You can use the CSS property page-break-before (or page-break-after ). Just set page-break-before: always on those block-level elements (e.g., heading, div , p , or table elements) that should start on a new line.
page-break-before: auto instead of . page-break-before: always. The "auto" will break the page only if the contents are at the end if the page, this will prevent breaking the page and leaving a lot of blank space.
always − A page break should be forced before this element's box. avoid − No page break should be placed before the element's box if at all possible. left − Force one or two page breaks before the element's box, such that the next page on which an element is printed will be a left-hand page.
Well, Because we don't have live example of your code Unfortunately is very hard to finger out the solution but the good news is I can provide some information about it might works but not sure.
I hope this will help you to fix your problem and let me know which the most it works for you. Also let me know if you have any question.
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