CSS Page-Break Not Working in all Browsers
Parent elements can not have float
on them.
Setting float:none
on all parent elements makes page-break-before:always
work correctly.
Other things that can break page-break
are:
- using
page-break
inside tables - floating elements
inline-block
elements- block elements with borders
page-break-after does not work in Chrome
It is a hack, but Chrome doesn't support page-breaks very well. So try to use this instead:
<body>
<main role="main">
<section class="tabs">
<div class="tabbed-content">
<div class="break-after">Page 1</div>
<div class="break-before">Page 2</div>
</div>
</section>
</main>
</body>
And add this to your css:
html, body, .main, .tabs, .tabbed-content { float: none; }
.break-after {
display: block;
page-break-after: always;
position: relative;
}
.break-before {
display: block;
page-break-before: always;
position: relative;
}
page-break-before: always not working as intended after updating chrome from v97 to v98
(1) Meh Option - Changing Margins: from None to either Default or Minimum seems to resolve our issue... We prefer None for saving pages on our site to PDF without a white border around the page, however Default looks just fine otherwise and we can use this.
(2) Better Option - Adding width: 100.25%
to the div with class controller-navbar-container
fixes this issue on this page and on every other page on the site as well. I am not sure why this is the case.
Page break not breaking
I found the answer
display: flex;
justify-content: center;
font-size: 10px;
I have this in my parent div as style when i remove it it works. Although i dont know why. I hope someone has the answer why this style is not letting the page break to work
page-break/webkit-region-break not working in chrome anymore?
Make sure the element with page-break-after: always;
is a block element. Another selector might be changing it to inline-block or something else which would prevent the break from being applied.
Also make sure the element is not within a float
ed element. Thanks RoadBump.
Related Topics
Ie8 Display Inline-Block Not Working
How to Select an Nth Child Without Knowing the Parent Element
Resize Font-Size According to Div Size
How to Wrap Text With No Whitespace Inside a ≪Td≫
Aligning Two Divs Side-By-Side
How to Specify Different Widths for Columns in CSS3
Bootstrap 3 - Desktop View on a Mobile Device
Add a CSS Class to Single Code Chunks in Rmarkdown
Css: 100% Width or Height While Keeping Aspect Ratio
Difference Between :First-Child and :First-Of-Type
What Does Auto Do in Margin: 0 Auto
Why Does .Foo A:Link, .Foo A:Visited {} Selector Override A:Hover, A:Active {} Selector in Css
Simulating Transform-Origin Using Translate
Css 3D Transform Doesn't Work If Perspective Is Set in the End of Property
How to Display a Reverse-Ordered List in Html