Hide form controls when printing an HTML page with CSS

后端 未结 6 828
被撕碎了的回忆
被撕碎了的回忆 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条回答
  •  有刺的猬
    2021-02-12 12:47

    This effect can be achieved in webkit browsers. I still can not find a way to do it in others, but it will work for webkit.

    @media print {
        input::-webkit-outer-spin-button,  
            input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }
    }
    

    Webkit actually treats those buttons as pseudo elements (with good reason) and provides a way to hide them. This is exactly the kind of behavior one would want, though being limited to just webkit is a bit annoying.

提交回复
热议问题