How to print selected div instead complete page

后端 未结 10 1862
滥情空心
滥情空心 2020-12-13 07:43

I have two divs: div1 and div2.

Maintaining the original css styles applied to the div2 element being printed.

I don\'

10条回答
  •  半阙折子戏
    2020-12-13 08:03

    You can only print a whole page, not part ofg a page. So, there is two options, you can either copy the content of one element into a new page and print that, or prevent the other element from being printed.

    You can use a media css to hide one element from printing. Example:

    @media print {
    
       .div1 { display: none; }
    
    }
    

提交回复
热议问题