"An issue has been identified with the page-break-* feature not functioning properly on both Chrome and

Despite the abundance of questions on this topic, I have yet to find a viable solution. Here is my HTML code:

<div class="row">
    <div class="col-xs-12">
      <div class="row print-break">
        <div class="col-xs-8 col-xs-offset-2">
          <!-- Some Content -->
        </div>
      </div>
      <div class="row print-break">
        <div class="col-xs-8 col-xs-offset-2">
          <!-- Some Content -->
        </div>
      </div>
      <div class="row print-break">
        <div class="col-xs-8 col-xs-offset-2">
          <!-- Some Content -->
        </div>
      </div>
    </div>
  </div>

Accompanied by the CSS:

@media print {
   .print-break {
      page-break-after: always;
      page-break-inside: avoid;
   }
}

I've observed that Firefox correctly inserts page breaks, but Chrome and Safari do not follow suit.

If anyone has insight on how to resolve this issue or can point out any mistakes I may be making, I'd greatly appreciate it.

Answer №1

Your specific code raises a few points for discussion, each correct on its own but contributing to the overall issue when combined.

The page-break-after property behaves inconsistently across different browsers, leading to unpredictable results. Therefore, it's best to rely on a simpler and more consistent approach.

In some cases, certain browsers may not initiate a page break within a div element if its parent container has a float or a specific width assigned to it.

Based on the provided code snippet, it seems like you might be utilizing Bootstrap. I noticed a nested grid structure where the outer column spans 12 units. This can impede page breaks as the Safari browser doesn't paginate children elements within a parent set to width: 100%.

If it's possible to eliminate the 12-unit nesting, your page breaks should function correctly.

Personally, I prefer implementing page breaks using an independent separator tag (like a div or span) for better readability and styling flexibility.

Additionally, there is no need to wrap every row in a separate row class; a simple clearfix can signal the start of a new row and serve as the same separation marker.

A restructured version of your code without nesting could potentially resolve the page break issue:

<div class="row">
  <div class="col-xs-8 col-xs-offset-2">
    Some Content 1
  </div>
  <div class="print-break clearfix"></div>
  <div class="col-xs-8 col-xs-offset-2">
    Some Content 2
  </div>
  <div class="print-break clearfix"></div>
  <div class="col-xs-8 col-xs-offset-2">
    Some Content 3
  </div>
</div>

Corresponding CSS adjustments would include:

@media print {
  .print-break {
    page-break-after: always;
  }
}

(The @media print rule may not necessarily be required in this specific scenario.)

Answer №2

Ensure that any element using page-break-after: always; is not contained within a parent element with the float property set to anything other than none;. Additionally, verify that the element is of type block; if it is an inline-block, the page break will not be applied.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The grid layout is being disrupted by a concealed input

As I work on styling my admin panels with Twitter Bootstrap, I've encountered a strange issue. Upon testing in Chrome 28 and Firefox, adding a simple hidden input seems to disrupt the grid layout. If the hidden input is moved into div.span6 or remove ...

problem with the video pathway in the javascript document

I'm currently in the process of putting together a Video gallery playlist using HTML, CSS, and JavaScript. So far, I've set up the html and css files along with two js files. The first js file contains all the video information as shown here: ...

pass the HTML output back to Python

I am currently working on a local website using Python to create a button that will open the door to my room from my phone through a Raspberry Pi. I have already created a Python program that successfully opens the door, but now I am trying to implement an ...

Issue with AngularJS causing HTML input field to limit the display to only three digits

Whenever I input a number with 4 digits or more (excluding decimals) into the designated box, it mysteriously disappears once I click away (blur). Could it be due to the currency filter causing this issue? Even though the model retains the value when logg ...

Incorporating a hyperlink within a confirmation return statement

Looking to include a link within a return confirmation <a onclick="return confirm('Make sure you've read our policies before downloading the App');">[...] The policies should be clickable at the end. ...

How to avoid clipping in Bootstrap 4 when a row overflows with horizontal scrolling

In order to allow for horizontal scrolling of all contained columns, I created a row using the row class. To implement this feature, I followed advice from a contributor on Stack Overflow. You can view their answer by following this link: Bootstrap 4 hori ...

What is the best way to insert an image between two sections using CSS?

As I work on a new webpage, I find myself stuck (yes, I'm a beginner :-) ). I have a header followed by a section, and I would like to place images in between the two. However, despite my attempts to position the images, they keep getting hidden "und ...

Ensure that breadcrumb links remain on a single line by using text truncation in Bootstrap 5

For creating breadcrumbs in Bootstrap 5, the documentation suggests the following code: <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="#">Home ...

A secret form input unexpectedly triggers the expansion of a table cell in IE7 (see image)

I've encountered a strange issue where a form inside a table cell with hidden inputs causes the cell to expand in IE7 once there are more than one hidden input present. Here is a screenshot showing the problem: Here is the HTML code: <table bord ...

Tips on positioning images to the left and right without causing text to wrap around them

I have successfully floated an image to the left of text with the following CSS. How can I achieve a similar effect with an image to the right of text on the same page? Do I need to use a clearfix between the left and right images? Thank you! .innercont ...

Can you explain the purpose of the URL function in the context of url("#foobar"

Currently, I am developing a CSS concatenator and one of the tasks involved is URL to absolute URL rewriting. For this process, I exclude any absolute URLs that start with http, https, etc. In the case of Django projects, they designate the following URL ...

Tips for creating a 3D illusion by coding a div or object to rotate around another object or div

I have reached a technical and intellectual roadblock. The issue at hand is this: I need the text to encircle an image and create the illusion that it is moving in front of or behind the image, while keeping the image static. Currently, 1) the rotating te ...

Retrieving CSS file using admin-ajax.php in WordPress

The website has been tested on GTmetrix and you can view the report here I am puzzled as to why admin-ajax.php is causing a delay of over 3 seconds in loading time on this particular page that I am attempting to optimize. It seems to be related to a CSS ...

Error encountered: $(...).pickadate is not defined as a function

I am currently working on a basic web project that involves a simple form where users enter their name, birthday, and university degree. I am utilizing Materialize and jQuery for this project. However, I have encountered a frustrating issue while trying to ...

What is the best way to stop other elements from becoming highlighted while dragging a devexpress component?

After updating my devexpress version to 12.1, I noticed that all draggable elements are highlighting background elements in Chrome (20.0.1132.47 m). For instance, when dragging a splitter, the entire page blinks. When dragging an ASPxPivotGrid or ASPxGrid ...

Using the alt attribute for background images in CSS

Dealing with alt tags for images is a challenge I haven't faced before. How can I add alt tags to all images on a website, even those used by the CSS background-image attribute? Since there isn't a CSS property specifically for this purpose, wha ...

JavaScript Bug Report

Currently, I am immersed in a project that encompasses various languages like HTML, JS, and PHP. While working on one of the PHP functions, I stumbled upon an unexpected anomaly. To dissect it better, I decided to break it down into simpler functions: &l ...

Is there a way to adjust the padding of html and body elements to 0 in Vue.js without interfering with the styling of bootstrap

In my Vuejs project, I am designing a bootstrap navbar that has left and right margin spacing, even though I have not added any body or html padding. When I navigate to the welcome.blade.php file and set the body and html padding to 0 as shown below: *{ ...

What is the best way to create a full-width dropdown menu with a nested dropdown in React JS?

https://i.sstatic.net/uoX2x.png Looking for a dropdown menu with nested dropdowns inside, I have tried using the standard bootstrap navbar method but haven't been successful. Here is my current code: <div class="dropdown"> <button class= ...