Employing CSS for page breaks, while contained within a DIV that is absolutely positioned

I have integrated the ASP.NET AJAX ModalPopupExtender into a webpage. The popup displays details of customer orders that need to be printed, with each order ideally on a separate page.

Unfortunately, the CSS page-break-after style doesn't seem to work in this case due to the ModalPopupExtender setting the containing div to position: absolute.

Any suggestions for a workaround?

For reference, here is an example HTML page showcasing the issue:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Printing Pagination</title>
    <style type="text/css">
        div
        {
            padding: 10px;
            margin: 10px;
        }
        div.outer
        {
            border: solid 5px green;
            position: absolute;
            top: 100px;
            left: 100px;
            width: 200px;
        }
        div.page
        {
            border: solid 5px red;
        }
    </style>
    <style type="text/css" media="print">
        div.outer
        {
            border: none;
        }
        div.page
        {
            page-break-after: always;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="page">
            This content should appear on page 1 when printed.
        </div>
        <div class="page">
            This content should appear on page 2 when printed.
        </div>
        <div class="page">
            This content should appear on page 3 when printed.
        </div>
    </div>
</body>
</html>

Answer №1

Is it possible to simply incorporate this snippet of code into your print design?

div.outer { position: relative; }

Although it may seem straightforward, during the printing process, I highly doubt that the client or viewer of the report would be interested in positioning and would prioritize the content instead, right?

Answer №2

Dealing with a similar issue, I found a solution while utilizing the gridster plugin along with several absolutely positioned divs. To prevent any cut-off elements, I successfully implemented a tweak by adjusting the margin-top property for those specific divs so they would be shifted below the page break.

For anyone facing the challenge of repositioning multiple elements and working with Sass, consider this approach:

@for $j from 1 through 10 {
  &[data-ANOTHER-ATTR="#{$j}"] {
    margin-top: #{ANOTHER_OPERATIONS}px;
  }
}

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

Error 404: Troubleshooting an Azure Issue with Custom TrueType Font in .NET MVC 5

I am encountering an issue that has been previously addressed. Despite implementing the suggested solutions, the problem persists. In an effort to enhance my project, I downloaded two custom ttf fonts called Monterey and Bakery. Both fonts have been succ ...

using angularjs to send multiple items to a webapi

In my ASP.NET WebApi Application, I have the following controller: [Route("api/PutItem/")] [HttpPut] public IHttpActionResult PutItem(Guid id, Item item) { if (!ModelState.IsValid) } Additionally, in my AngularJs service "Items," ...

The striped color override feature in Bootstrap appears to be malfunctioning in Internet Explorer 8

I have come across several discussions regarding this topic with various suggestions. My current objective is to make the alternating rows in Bootstrap (2.3.2) appear darker in Internet Explorer 8. To achieve this, I attempted to override the style by impl ...

Is there a way to create space at the bottom after setting margin to auto?

I'm currently mastering Bootstrap v5.0 and experimenting with creating a webpage using Bootstrap. I've encountered an issue that requires assistance. Specifically, I'm trying to add extra space between two columns on smaller screens while ma ...

Leveraging webpack for CSS bundling

I'm currently working on bundling some NPM modules using webpack instead of utilizing a CDN. While I've successfully managed to integrate the .js files, I'm facing challenges with including the .css files for these modules. One example is ...

Using a local function within Node.js and referencing it with the <%%> tag in a document

I am currently working with Node.js and attempting to utilize a local function within a document that requires the JSON I send in the res.render. Is there a method to achieve this? Below is an example of how I attempted to implement it: <%local_vari ...

Caution: It is important for each child within a list to have a distinct "key" prop when using react-input

I'm currently facing an issue with the following code snippet: {array.map((item) => ( <> <input key={item.id} type="checkbox" /> ...

What's the best way to navigate across by simply pressing a button located nearby?

Hey there! I'm new to JavaScript and I'm working on a shopping list page for practice. In my code, I can add new items to the list, but what I really want is to be able to cross out an item when I click the "Done" button next to it, and then uncr ...

The art of creating dynamic BoundFields in ASP.net

Within a GridView, I am attempting to display one column or another based on a public Boolean property: <Columns> ... <asp:BoundField Visible="<%= !ShowPurchaseDate %>" DataField="Published" HeaderText="Publicerad" SortExpression ...

Tips for adjusting the content direction of a Popover

I am currently working on a component that includes the following code: import { Popover, PopoverTrigger, PopoverContent, PopoverBody, Portal, Button, } from "@chakra-ui/react"; import { ReactNode } from "react"; import { Co ...

Issues with Bootstrap offsetting columns within a fluid row

I am currently working on a fluid design layout, where I need to place form group elements inside the row-fluid with one specific condition - they must be aligned to the right side. <div class="row-fluid" style="background-color: #332619; color: #fff ! ...

Using HTML5 to display the {{data}} extracted from a JSON file right in the center of the text

Can someone help me with a question about working with html and angular5? <span [innerHTML]="'client.acceptance.explanation'| translate"></span> <span><b>{{data}}</b></span> I have text stored in a json file ...

`CSS3 animations utilizing keyframes and transformation`

Looking to replicate a similar effect using CSS animations: I've created a file working with keyframes for the animation, but it's not functioning as desired. My goal is to have the circles complete a full rotation on their axis, starting from ...

Delete the right border on the items in the bottom row

I have a list of items with three rows. I want to separate the first and second row with borders, so I added a right border to those items but excluded the third row from having borders. .test-row { display: grid; grid-template-rows: 1fr 1fr 1fr; ...

Can the element be partially covered while remaining exposed to the cursor?

In the design, I am looking to add overlay images to the menu while ensuring that the entire menu item is clickable, not just a portion of it. Currently, only the top part of the button is clickable in the implementation found at .elem { display: inl ...

Can you provide me with steps to customize my mouse cursor specifically when hovering over the canvas?

I own a .cur file and I desire to utilize that specific cursor image whenever my mouse hovers over the canvas element in Google Chrome. <body> <canvas id="canvas" width="600" height="405" style="position:relative; background: black;" onc ...

Various resource files for conducting integration tests on an asp.net application

In my current asp.net project, I am utilizing a resource file to specify the REST api endpoints that are being used. The application's functionality can vary based on the data received from these services. I am interested in conducting integration te ...

The image in the row wrap container spills over slightly

Even though all the items within that container are wrapped properly as article, there is an issue with the right border of the image overflowing the container's article border. My temporary solution involves adding a mediaquery @1041px and a small a ...

What is the best way to automatically populate the date and time fields in PHP MySQL without manual input?

Is there a way to automatically populate these two input fields without any manual input? <input type="time" name="Time" id="Time" value="" /> I am looking for a solution to automatically fill the date and ti ...

Retrieving JSON data enclosed in quotes from an ASP.NET WebMethod

Recently, I have been working on an asp.net page that contains a WebMethod designed to pass JSON data back to my JavaScript. Below is the code snippet for the web method: [WebMethod] public static string getData(Dictionary<string, string> d) { ...