Using -moz-transform CSS does not effectively prevent unwanted page breaks when printing in Firefox

I am facing a challenge with printing two tables, named header and details, on separate pages. The structure of the tables is as follows:

<table id="header">
   <!-- multiple rows here -->
</table>
<table id="details" style="break-before: always;">
   <!-- multiple rows here -->
</table>

The issue arises when the number of rows in the header table causes its last row to spill onto the next page, which I managed to fix for Google Chrome by adjusting the zoom level:

$("body").css("zoom", 0.93);

However, my attempts to resolve this problem for Firefox using CSS transformations have been unsuccessful:

$("body").css("-moz-transform", "scale(0.9)");

It appears that Firefox maintains the original page break even after scaling down, leading to the last tr of the header table spilling over to the second page. I also tried utilizing the break-before property within the table row but did not achieve the desired outcome:

<!-- last row of header table -->
<tr style="break-before: avoid;">

If anyone has insights on how to overcome this issue specifically for Firefox, your assistance would be greatly appreciated. Thank you!

Answer №1

It's quite surprising that the following code actually works even though it was thought to be impossible for the page margin to increase as the contents scaled down on Firefox:

/* For Chrome */
$("body").css("zoom", 0.93);
/* For Firefox */
$("body").css("-moz-transform", "scale(0.93)");
$('head').append('<style>@page{margin: 0.3cm;}</style>');

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

Accessing the initial element inside a DIV using CSS

In the structure of my code, I have a WYSIWYG editor enclosed in a table within a div element: <div class="mydiv"> <li> <table>My WYSIWYG</table> </li> </table> Within the WYSIWYG editor itself, there a ...

Interacting with server-side data using JQuery's $.ajax method and handling JSON

The JSON response returned from the request is not being recognized. request = $.ajax({ url: "form_handler.php", type: "post", dataType: "json", data: serializedData }); The PHP code within form_handler.php that generates ...

Which font file format is the most suitable for my website?

I've been doing some research on fonts for my website, and I've come across various formats available. Now I'm curious about what the standard format is or if there are multiple standard formats. .TTF (True Type Font) .EOT (Embedded OpenTyp ...

Creating a custom jQuery plugin with an undefined JavaScript function

Having some trouble with my custom jQuery plugin. Browsers are throwing errors saying a function inside the plugin is undefined. Could someone take a look at my code and spot any mistakes? (function($){ $.fn.myCustomPlugin = function( ) { return ...

React JS tutorial: deleting an entry from the browser's localStorage

I am currently working on an App that fetches data from an API and updates it randomly every 3 seconds. The user has the ability to print the data by clicking a button, which can also be used to stop the random updates. I have managed to implement this fun ...

Is it possible to transfer a Mongo connection to JQuery code using socket.io?

I'm currently working on setting up a global MongoDB connection in my node.js web app. Here is what I have so far: var MongoClient = require('mongodb').MongoClient; var mconn = null; MongoClient.connect('mongodb://myHost:27017/users&a ...

Display WordPress die errors as an alert message

During my current project, I have encountered a function that is working well so far except for the issue of displaying an error message in an alert popup when the function fails. This particular function involves Ajax scripting. Below is the code snippet ...

When using jQuery and AJAX, the functions each, if, post, and .html work properly but occasionally erase data inexplicably

I have a PHP page containing FedEx and UPS tracking numbers stored in a MySQL database, which are displayed within DIVs with the class "trackingnumber". Using JavaScript, I loop through these divs to retrieve the ID and then send it to a PHP page that fetc ...

Obtaining specific data from an ajax response using a condensed key in Rails

Within a shopping application, I am looking to implement ajax for instant updates to the total price of the cart. The relevant code can be found in views/carts/index: $("input#number").change(function(){ var current_quantity = $(this).val(); var url ...

Utilizing data attributes and JavaScript to dynamically assign a class to carousel navigation items

Hello there! I recently created a carousel and carousel navigation system using Bootstrap. I am now trying to figure out how to detect the value of 'data-slide-to' and then apply a specific style to the corresponding navigation item based on that ...

Engaging with tasks like incorporating fresh elements into JavaScript code

I am looking to implement an event listener that triggers whenever a new element is added to the document or any of its children. Can someone recommend a method for accomplishing this? ...

What is the best way to populate a textarea element in Jade with text without any whitespace?

My current solution is functioning perfectly: textarea. #{myObject.myVar} Despite the success, Jade throws a warning when compiling the file: Cannot read property 'myVar' of undefined This warning makes sense since myObject may not be p ...

CSS Grid: Dividing items equally based on the number of items present

Currently, I am delving into grid layouts in CSS and experimenting with code to divide a row. Here is the snippet I am playing around with: .grid-sample { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; row-gap: 4rem; padding: 0 5rem ...

Using jQuery to toggle CSS properties

I'm having trouble switching between a CSS column layout and a normal layout for a div element with the ID 'article'. The jQuery script I wrote doesn't seem to work properly, as the entire thing disappears. Can anyone advise me on how t ...

The pagination feature in DataTable does not retain the edited page after making changes

I have been encountering an issue while using DataTable serverside processing. My datatable includes an edit column, and when the edit link is clicked, a jQuery dialog box appears. After submitting the dialog box, an ajax.reload call is made. However, the ...

After the completion of an AJAX request, variables are not refreshed

On my webpage, I have a grid displaying various 'objects'. These objects can be edited by clicking on the 'Edit' option, which opens a modal window using ui.dialog. The modal window loads a template with inputs and textareas to edit the ...

unable to retrieve the chosen item from the dropdown menu

How can I retrieve the value of the selected item from a dropdown menu without getting an undefined error? You can find my code on Jsfiddle. Can anyone spot what might be causing this issue? <select class="ddl_status" id="status_ddl_20" style="display ...

Customizing Image Layout with jQuery Masonry - Tips for Aligning Images

I've successfully created a jQuery masonry layout that showcases recent posts from various categories on the homepage. However, I'm facing two challenges and seeking help to address them: How do I remove the small white gaps beneath some ima ...

Maintain form activity post submission using jQuery's addClass and removeClass methods

There is a button on my website that, when clicked, reveals a form. The code I am using for this functionality is: $('#theform').addClass('hidden') $('#theform').removeClass('hidden'); <div id="theform" c ...

Include a character on the right side without shifting the text to the left

Below is the HTML code I am currently working with: <div class="last_img"> <p>Galutinė žetono išvaizda:</p> <span class="zetin11">A</span> <span class="zetin12">A</span> < ...