The HTML/CSS Progress Bar appears on the browser but does not appear when attempting to print the document

I am currently assisting a friend with creating a resume and we wanted to include a visually appealing progress bar for the skills section.

After successfully implementing the progress bar and seeing it display correctly in the browser, we encountered an issue when attempting to save the page as a PDF. The progress bar does not appear in the saved PDF file; instead, there is just a blank space where it should be.

Here is the code snippet for the progress bar:

.w3-progress-container{
  width:90%;
  height:1.5em;
  position:relative;
  background-color:#f1f1f1;
  border-radius:7px;
  height:12px;
  margin-top: 5px;
  background-color: #d5d4d4;
}
.w3-progressbar{
  background-color: #0060A6;
  height:100%;
  position:absolute;
  line-height:inherit;
  border-radius:7px;
}

.management{
  width:93%;
}

Link to live demo on JSFiddle

We are puzzled by why the progress bar is not rendering when saved as a PDF. Any insights or suggestions would be greatly appreciated!

Thank you!

Answer №1

Insert the following CSS into your stylesheet:

@page {
    size: A4;
    margin: 0;
    box-shadow: initial;
    -webkit-print-color-adjust: exact; 
}
@media print {
    html, body {
        width: initial;
        height: initial;
        margin: 0;
        padding: 0;
        overflow: hidden;
        -webkit-print-color-adjust: exact; 
        -webkit-box-shadow: initial;
        box-shadow: initial;
    }
}

View example here: https://jsfiddle.net/w8kaw4y1/4/

Answer №2

insert the following code into your style section

-webkit-print-color-adjust: exact;

for example

    @page {
        size: A4;
        margin: 0;
        box-shadow: 0;
        -webkit-print-color-adjust: exact; 
    }
    @media print {
        html, body {
            width: 210mm;
            height: 297mm;
            margin: 0;
            padding: 0;
            overflow: hidden;
            -webkit-print-color-adjust: exact; 
            -webkit-box-shadow: none;
            box-shadow: none;
        }
    }

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

Ways to minimize the loading time of contents within the Dropdown

I am facing an issue with the loading time of my dropdown list. When trying to load 100,000 items on button click, it takes too long. Is there any way to reduce the loading time? Looping through Products for (int i = 0; i < 100000; i++) { ...

Prevent page refresh when submitting a form using PureCSS while still keeping form validation intact

I'm currently implementing PureCSS forms into my web application and facing a challenge with maintaining the stylish form validation while preventing the page from reloading. I discovered that I can prevent the page reload by using onsubmit="return f ...

Jquery div mysteriously disappearing without explanation

I need some help with my image options. Whenever I hover over the image, the options appear below it. However, when I try to move down to select an option, they disappear. I have configured the slideUp function so that it only happens when the user moves a ...

Wordpress dynamic content enhanced with Bootstrap carousel

My current issue involves a Bootstrap carousel that I've implemented in WordPress. While the carousel itself is functioning properly, I'm having trouble getting it to link to specific articles when the images are clicked on. Can anyone offer advi ...

Discrepancy in Angular Material Buttons with theme design

I recently installed Angular 10 along with Angular Materials using the command ng add @angular/material I opted for the custom theme: Purple/Green The next step was to add a Toolbar by simply copying and pasting code from Google's site. However, I a ...

How can I iterate over an array in JavaScript to create posts for an HTML feed using Bootstrap?

I have created a simple Bootstrap website in HTML that resembles a news feed. To populate the feed with various posts, I am using Javascript to work with arrays containing images, headlines, and captions for each post. My initial approach involves looping ...

Creating unsightly class names using Node.js

Is it possible to automatically create random and unattractive class names? For example, is there a tool or plugin that can substitute the .top-header class with something like .a9ev within my CSS code? It would also be ideal if the class name in the HTML ...

PHP Ajax Image Uploading and Storage

Is there a way to effortlessly upload an image and save it in the uploads folder without any page refresh? Not only that, but can we also have the uploaded image displayed on the screen within a designated div section? Unfortunately, I seem to encounter a ...

Mastering the application of map, filter, and other functions in Angular using Observables

After creating this Observable: const numbers$:Observable<any>=Observable.create((observer)=>{ for(let i=0;i<5;i++) observer.next(i); }) I attempted to use map and filter as shown below: numbers$.pipe(map(x=>{x+110})).subscr ...

Interactive JavaScript Linkage

Recently, I came across some code that I inherited (definitely not mine!) which uses a session variable in the HTML header to link to a specific javascript file. For example: <SCRIPT language="javascript" src="../JavaScript/<%=Session("jsFileName") ...

Contrasting box-shadow behavior observed in Chrome versus Firefox

I'm working on a project and aiming to achieve this design: https://i.stack.imgur.com/YflaU.png To test it out, I created a sample page with the following code: p { display: inline; background-color: yellow; box-shadow: 10px 0px 0px red, -1 ...

Guide to animate the appearance of a div from a specific location

I have a div that smoothly slides out when a label is hovered over. HTML: <div class="cellDataViewTdmStatus divCell userSitesCol7"> <label class="lblViewTdmStatus">View Status</label> </div> <div id="tdmStatus" class="hid ...

Vertical Alignment of Navigation Bar in Bootstrap 4

I am trying to align the center of my navigation bar using the "Cover" Bootstrap 4 template. Please find the current code provided below. <div class="cover-container d-flex h-100 p-3 mx-auto flex-column"> <header class="masthead mb-auto"> ...

Leverage the power of the modal component in your ReactJS

I'm facing an issue with the antd library. Even after installing it from the official site and importing the modal component, it's not functioning properly for me. I've carefully checked everything in my code and everything seems to be fine. ...

Is there a way to use HTML to prevent the user from navigating away from the current page when submitting a form? Could jQuery, PHP, or a combination of

Is it achievable to send a message using PHP and keep the user on the same page after clicking "Send Message" button? Perhaps changing the submit button to a success message on the following page: . Can this task be accomplished with PHP and jQuery? ...

What is the best way to align <h2> and <img> elements that are set to display as inline-block?

I've been experimenting with aligning h2 and img (icon) elements and although I added display: inline-block, they ended up shifting to the left of the section. Is there a way I can center them instead? HTML: <h2>Coffee</h2> <img src=&q ...

Setting a fixed data value within a div for subsequent retrieval through a function

I found a helpful example that demonstrates how to convert numbers into words. You can check it out here. The function for converting numbers into words is implemented in the following HTML code: <input type="text" name="number" placeholder="Number OR ...

Enhancing x-axis presentation in D3.js-generated charts

I created a bar chart using D3.js, but I have encountered an issue with one of the values on the x-axis being too long. I attempted to use CSS properties like text-overflow: ellipsis, width: 10px, and overflow: hidden to abbreviate values that exceed a cer ...

Restricting the output from BeautifulSoup

After spending some time working with BeautifulSoup and Selenium, I have encountered a problem that has me stumped. I am trying to extract the HTML from the first 6 rows of a table, but these rows do not have any shared class or ID. Here is the structure ...

What is the best way to create an interactive menu icon that includes dropdown options using MUI menu features?

i am looking to create a component similar to this https://i.sstatic.net/fwIB0.png currently, I am utilizing a material UI pop menu in my project below is the JSX code snippet <div className="navMenu" style={{ position: "relative" ...