How do I hide an element when printing a web page?

前端 未结 10 1058
-上瘾入骨i
-上瘾入骨i 2020-11-22 03:34

I have a link on my webpage to print the webpage. However, the link is also visible in the printout itself.

Is there javascript or HTML code which would hide the lin

10条回答
  •  臣服心动
    2020-11-22 04:08

    In your stylesheet add:

    @media print
    {    
        .no-print, .no-print *
        {
            display: none !important;
        }
    }
    

    Then add class='no-print' (or add the no-print class to an existing class statement) in your HTML that you don't want to appear in the printed version, such as your button.

提交回复
热议问题