Experience seamless printing on both Mac and Windows devices with Chrome. With the ability to print using the system dialog

I recently encountered a puzzling issue with printing in Google Chrome for Mac that I am currently troubleshooting. I noticed that when I use the "Print Using System dialog" option, the @page within the print styles gets ignored, resulting in incorrect printouts. However, when I print using the built-in Chrome print dialog, everything seems to work just fine.

In Windows Chrome, both the system dialog and the regular dialog fail to recognize the @page properties.

The reason I have defined @page properties is because my version of bootstrap already includes them, and I need to override them for my specific needs.

Here is the code snippet:

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@page
{
    margin:10cm 10cm;
}
@media print
{
    @page
    {
        margin:0 !important;
    }
}
</style>
</head>

<body>
<h1>Hello World</h1>
</body>
</html>

For a working example, you can visit:

Answer №1

After experimenting with various methods, I finally discovered a solution that works perfectly on Chrome version 32. The key is to set the @page margin value within the print media query to 0 without using !important. Using any other value will cause the bug to occur:

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@page
{
    margin:10cm 10cm;
}
@media print
{
    @page
    {
        margin:0;
    }
}
</style>
</head>

<body>
<h1>Hello World</h1>
</body>
</html>

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

What is the best way to dynamically adjust the top CSS of an element when it is positioned at the top or

Is there a way to dynamically set the top CSS when an element is over the top or bottom of a page? First, hover over the first cat image. It's working fine. http://image.ohozaa.com/i/480/7YpWei.jpg When I scroll the page to the bottom and hover ove ...

Themes in Next.js with a splash of color

Is there a way to implement theming with color picking for elements? Check out the example here. I've explored using CSS variables and changing the document classname, but I'm uncertain if this is the best approach. @tailwind base; @tailwind com ...

Can @keyframes be iterated through CSS (particularly Stylus)?

Here is some Stylus code I'm working with: for i in (1..3) .l:nth-child({i}) opacity (i / 5) When executed, the output looks like this: .l:nth-child(1) { opacity: 0.2; } .l:nth-child(2) { opacity: 0.4; } .l:nth-child(3) { opacity: 0.6; } ...

Effortlessly sleek horizontal navigation bar designed with Liquid CSS

I've been exploring online tutorials to create a responsive horizontal drop-down menu navigation bar using just CSS and HTML. The tutorial process has been smooth so far, but I'm aiming to make my navigation bar fluid so that it adjusts seamlessl ...

What is the best method for creating a top margin that is dependent on the height of the browser?

Is there a way to make the CSS margin: top; on my HTML main_content element relative to the browser window? I want the main_content to always stay at the bottom of the browser window. How can I achieve this? I attempted the following code, but it didn&apo ...

Tips for initiating the transfer of data to a modal through bootstrapping

<input type="button" class="btn btn-primary btn-lg btn-block" value="(AAP)" data-toggle="modal" href="#teklif{$foo}"> I am looking to pass the foo value. foo == number such as 0,1,2.. <div id="teklif" class="chat_modal modal fade hide"> ...

Creating a water vessel design using CSS

Despite going through the JS tutorial, I still struggle with it and need some assistance. I believe using a jsfiddle would be helpful. I am attempting to use JS to create a small box that changes color from green to empty based on the fullness of a "wate ...

Adding products to an owl-carousel in an HTML document using JavaScript

When I try to add my products to an owl-carousel using JavaScript, the display is not correct. My HTML code looks like this: <div class="container mt-5 mb-5" data-aos-anchor-placement="top-center"> <div class="owl-carouse ...

I'm struggling to make the jquery parentsUntil function work properly

Would appreciate some help with using the jquery parentsUntil method to hide a button until a radio box is selected. I've been struggling with this for a few days now and can't seem to figure out what I'm doing wrong. Any insights would be g ...

Can anyone guide me on repositioning material ui tabs to appear below my content and ensuring that the content expands to full height

Is there a way to position the Material UI tabs from Material UI tabs below the content area instead of above it? I am currently using them in my project and would like this specific layout. <md-tab-group> <md-tab label="Tab 1"> Co ...

Exploring the position property in CSS

Seeking assistance as a CSS beginner. Currently working on a project where I have managed to position container_main right next to container_menu, utilizing the remaining screen space by assigning them relative and fixed positions, respectively. container ...

What is the best way to incorporate a div below an image in Ubergallery?

I have integrated the jquery ubergallery into my website, and I am trying to add a new div below the main photos for additional content such as share buttons and comments. I tried using the code that worked with colorbox, but since ubergallery uses colorbo ...

Show a dynamic Swiper carousel upon selecting a thumbnail in an image gallery

I am in the process of creating a thumbnail gallery that includes a slider feature using Swiper. The default setup has the slider hidden, and once an image is clicked, the slider should appear with the selected image. To close the slider and return to the ...

Modifying Table Cell Backgrounds Based on Value in React Tables

I am currently utilizing reactstrap to design my table and employing axios to interact with my backend data. The objective is to dynamically change the background color of a cell based on its value. For instance, if the cell value is less than 0.25, it sh ...

Seamless blend of images with a stunning mosaic transition effect

I attempted to create a mosaic effect on my carousel similar to this example: , but not exactly like this. I want to include control buttons for next and previous, and have images in HTML tag. However, my attempt is not working and I need help. This is ...

Challenges with jQuery parent method reaching the grandparent element

Hey, I'm a newbie to jQuery and I'm trying to make changes to divs that are two levels above the function trigger: Here's my initial attempt: I try to locate the closest '.node' which is the parent of all other divs and then modif ...

CSS layout: The full-width header should align its left margin with the centered content-div

Can someone help me out with a solution to my problem? My page has a 1040px centered div for content, menu, and footer. I want the header image to align with the left margin of the content div and expand towards the right side for higher screen resolutio ...

What is the best way to ensure the parent element adjusts to fit its floated children, without exceeding the width of the window?

I am attempting to center a group of floating elements, but due to them being displayed in masonry style, I cannot set them as inline. It is clear that a container is necessary, but I have been unable to find information on how to achieve this: Please dis ...

Opacity: When the value is set to 0, the element remains invisible even when hovered over

I'm encountering an issue with configuring an element to have absolute positioning and a width and height of 100% while setting its opacity to 1.0. To summarize, here is the HTML code I am working with: <ul class="properties"> <li style ...

Unique CSS shadow design & alternative solutions

I'm currently working on some HTML/CSS code and I am looking to implement a unique shadow effect with a custom width and height around a div element. https://i.sstatic.net/3SnXV.png Could anyone provide guidance on the most effective method to ach ...