How to print scrollable DIV content

前端 未结 5 1779
鱼传尺愫
鱼传尺愫 2020-12-16 14:44

There is a website that I would like to print the div content of. The problem is that the div is scrollable and I\'m not able to print all the content. I\'ve tr

5条回答
  •  我在风中等你
    2020-12-16 15:15

    My answer is based on the ones given by @Porschiey and @Paul Roub with a slight addition.

    Their given solution did work for me in most cases except for some where the

    that I wanted to print had a CSS set to position: fixed. In the resulting print, this would usually contain only the content that was able to fit in the actual size of the
    on the loaded page.
    So, I also had to change the position CSS attribute to something like relative so that everything could get printed. So, the resulting CSS that worked for me is this:-

    {
        display: block; /* Not really needed in all cases */
        position: relative;
        width: auto;
        height: auto;
        overflow: visible;
    }
    

提交回复
热议问题