How do I print the entire bootstrap modal where content in modal body is scrolled out of view

后端 未结 5 809
我寻月下人不归
我寻月下人不归 2020-12-08 03:18

The problem is that the user has to scroll down to view all of the content within the modal body. However, when I print the modal the only part that is printed is the part t

5条回答
  •  暖寄归人
    2020-12-08 03:55

    I think you can easily do that with CSS using @media print:

    If there is opened bootstrap modal window, will be printed content of modal (it can be more than one page), in other case content of window.

    @media print {
        /* on modal open bootstrap adds class "modal-open" to body, so you can handle that case and hide body */
        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 */
        }
    }
    

    Also you can add button on footer of modal for printing:

    
    

提交回复
热议问题