Hide form controls when printing an HTML page with CSS

后端 未结 6 844
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 12:20

Certain HTML form elements have extra UI attached to them, like the up/down arrows on number. When printing the page however, those buttons are no longer needed, as

6条回答
  •  Happy的楠姐
    2021-02-12 12:46

    try to use a hidden test on screen and then show it on print

    @media print {
        .hideOnprint {
            display: none;
        }
        .hideOnScreen {
            display: block;
        }
    }
    @media screen {
        .hideOnprint {
            display: block;
        }
        .hideOnScreen {
            display: none;
        }
    }
    

    affect the text with the class hideOnScreen and the input with the class hideOnPrint

提交回复
热议问题