Adding a scrollable feature to a Bootstrap Modal seems to be generating additional unnecessary pages at the

I need help with my scrollable bootstrap modal that has a print button on top. When the user clicks the button, I want to print the modal content. Here is the code snippet: HTML :

<div class="container-fluid" id="body-noPrint">
    /* HTML BODY CONTENT */
</div>

<div id="print-content">
     <!--PRINT PREVIEW MODAL MARKUP-->
        <div class="modal fade" id="printViewModal" tabindex="-1" role="dialog">
              <div class="modal-dialog">
                    <div class="modal-content">
                          <div class="modal-header">                                
                                <button type="button" class="btn btn-primary pull-right" id="modal-Printbtn"><span class="glyphicon glyphicon-print" aria-hidden="true"></span> Print</button>
                          </div><!--MODAL HEADER CLOSE-->
                          <div class="modal-body">
                              <!--DISPLAY THIS ROW AT MODAL VIEW-->
                                <div class="row">
                                        /* HEADER UI */                     
                                </div><!--MODAL VIEW HEADER CONTENT CLOSE-->

                              <!--DISPLAY THIS ROW AT PRINT-->
                                <div class="row" style="display:none;"> 
                                        /* HEADER PRINT */
                                </div><!--PRINT VIEW HEADER CONTENT CLOSE-->

                              <!--PRINT VIEW DYNAMIC TABLE-->
                                <div class="table-responsive" id="modalTable">
                                    <table id="modalTbl" class="table table-bordered">
                                      <thead>
                                        <tr class="active">
                                            <th class='col-xs-6'></th>
                                            <th class='col-xs-1'></th>
                                            <th class='col-xs-5'></th>
                                        </tr>
                                      </thead> 
                                      <tbody>               
                                      </tbody>           
                                    </table>                            
                                </div>                                                                                        
                        </div>                
                    </div>
              </div>
        </div>
</div>

JS :

$('#prntBtn').click(function(){
    window.print();
});

CSS :

@media print{
  /* Below CSS Makes Modal Content Visible At Print */
    body.modal-open {
        visibility: hidden;
    }

    body.modal-open .modal .modal-header,
    body.modal-open .modal .modal-body {
        visibility: visible;  /* make visible modal body and header */
    }

    body.modal-open .modal {
        position: absolute;
        left: 0;
        top: 0;
        margin: 0;
        padding: 0;
        overflow: visible!important;
    }

/*Print Preview Modal Styling CSS*/    
    #printViewModal .modal-dialog {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
    }

    #printViewModal .modal-content {      
      height: 100%;
      border-radius: 0;
      overflow:auto;
    }

    #printViewModal *{
        font-size:x-small !important;
    }

    #modalTbl thead tr > th{
        text-align:center;
    }

    #modalTbl tbody tr > td{
        text-align:left;
    }

    #modalTable{
        margin-top:10px;
    } 
}

I received advice from Stack Overflow suggesting I replace 'visibility : hidden' with 'display : none', but this resulted in a blank page when printing.

If anyone can offer guidance on how to avoid these extra printed pages while maintaining the modal layout, it would be greatly appreciated.

Answer №1

By activating the option for [Background graphics], you will be able to view additional elements that are printed on your page. This feature can assist in identifying the underlying issue.

https://i.sstatic.net/AbC8Y.png

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

Utilize JSON or an environment file to pass dynamic values to an npm script

I've been working on setting up an npm script for deploying react apps (specifically using create-react-app). However, I'm facing a challenge in setting the S3 bucket url string in either an environment variable or JSON file. This way, I can easi ...

Is the container in semantic ui being breached by a segment overflow?

I've recently started learning Semantic UI. One issue I'm facing is that the width of the "segment" overflows the "container." Check this JSFiddle for more clarity. Are there any alternative solutions? In addition to the grid system, I'm ...

The checkbox is not showing the check mark accurately

I am currently working on a React form where I am trying to retrieve the status of a checkbox element from local storage using the useEffect hook. const [checkbox, setCheckbox] = useState(false); useEffect(() => { setCheckbox(localStorage.getItem(&ap ...

What is the reason behind the image not displaying before the AJAX request is initiated and then disappearing once the request is completed?

I am attempting to display a "loading" gif while my AJAX request is being processed. Below are the functions I am using: beforeSend: function () { $('.form-sending-gif').show(); console.log("The beforeSend function was called"); } and ...

Can someone help me troubleshoot the issue I'm having with this jQuery API function?

Greetings everyone, I'm facing an issue with my jQuery code. I am attempting to use the CoinMarketCap API from cryptokickoff to showcase cryptocurrency statistics on my website. I understand how to display them, but the appending process to my column ...

Guide on adding markers using Google Maps API based on specific criteria

Hi there, I need assistance in developing the following requirements. In my database, there is parking lot information. Let's say each parking lot has two attributes: id and address. Via a spring controller, I am passing a list of parking lots t ...

Tips for resolving the final item issue in Owl Carousel when using right-to-left (RTL)

Encountering a bug with the rtl setting in owl-carousel. When the rtl is applied to the slider and I reach the last item, the entire slider disappears! Here's the code snippet: var viewportWidth = $("body").innerWidth(); if (viewportWidth & ...

Creating a sidebar that extends to the bottom of the webpage using

My friend is currently designing his website, and he has encountered an issue with the sidebar. He wishes for the sidebar to extend all the way down to the bottom of the page rather than just the visible portion within the browser window. You can view the ...

Showing off HTML tags within react-json-tree

I have incorporated the following npm package into my project: https://www.npmjs.com/package/react-json-tree My goal is to showcase a json tree in react, but I am facing a challenge on how to include an HTML tag as a JSON value. Are there any alternative ...

What is the best way to prevent a jQuery hover event from adding a text-shadow to the CSS?

Currently, I am facing an issue with a jQuery event that triggers a text-shadow effect: $(".leftColumn").hover(function (){ $(".leftColumn h2").css("text-shadow", "0px 2px 3px rgba(0, 0, 0, 0.5)"); },function(){}); The problem arises when the text-shad ...

Can Google Charts be integrated with $refs in VueJS?

I'm currently working on implementing a timeline chart with Google Charts. The chart is displayed within its own component, which I later invoke from a higher-level parent component. However, I've run into an issue where the drawChart function re ...

Adding custom CSS and JavaScript to the TYPO3 backend: A step-by-step guide

Is there a way to incorporate css and javascript files into the backend? I'm aiming to enhance custom created content elements with these files, making them more visually appealing for users. Platform: TYPO3 v9 Method: Composer Mode Purpose: Cu ...

Updating the error state of a TextField Component in React MaterialUI upon clicking a button

After clicking a 'search' button, I want to validate input fields in my input form. Many solutions suggest validating the input live as it is entered, but I prefer not to do this because some of the validation processes are costly operations, su ...

Tips for adding transparent images (such as logos) to an HTML website: I'm struggling with getting rid of the white background that appears on the website. Does anyone know how

Seeking guidance as a beginner web developer. I am currently working on adding a transparent logo to my website, but the white background is showing up behind the logo. How can I fix this issue? Here is the link to the image - Here is the HTML & ...

Navigating through dropdown menus using webdriver

I am having trouble selecting a specific element from a dropdown menu. The element I am trying to select is labeled Edit/ViewResume 1st Attempt For my initial try, I attempted to use the Action and Select class methods to choose the desired webelement ...

Angular JS allows for the display of text from a textarea upon clicking the submit button

Q] How can I display a single text message from a textarea upon clicking the submit button in angular-js? Here is the current code that I have: <html ng-app="myApp"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1 ...

Using forEach in React to simultaneously set multiple properties and return destructured output within the setState function

The following is the initial code snippet: setRows((rows) => rows.map((row) => selected && row.node === selected.id ? { ...row, row.a: "", row.b: "", row.c: "" } ...

Loading SVG images in advance

I am in possession of around one hundred simple SVG images, distributed among five different image folders. These images are currently retrieved on demand when they need to be displayed, which generally works well but occasionally results in flickering tha ...

The class is failing to be applied to the parent div that holds an id starting with the letter x

I have been attempting to assign a class to the parent container when the child element has the 'hidden' class. If not, then a different class should be added. function tagMissions() { if ($('span[id^="mission_participant_new"]').h ...

What is the best way to define the relative path and folder paths in HTML and CSS when working in Visual Studio 2012?

Working on a basic HTML project that includes css and javascript. Within the project folders named css, scripts, and images are used for organization. The project structure can be seen in the provided image. https://i.sstatic.net/OwCSL.jpg The issue that ...