Print Stylesheet - Converting inputs to text

后端 未结 7 486
孤独总比滥情好
孤独总比滥情好 2021-01-02 03:59

I\'ve got a table that has some boxes in it, and I want these to show as normal text when printing. I have set up a media=\"print\"

7条回答
  •  情话喂你
    2021-01-02 04:21

    I'm using ASP.NET and had the same issue.

    I solved it by adding a Label that corresponds to my Textbox, and had two classes set up:

    In @media screen:

    .hdnPrint {visibility:visible;display:block;}
    .visPrint {visibility:hidden;display:none;}
    

    In @media print:

    .hdnPrint {visibility:hidden;display:none;}
    .visPrint {visibility:visible;display:block;}
    

    For the textbox, I assigned the hdnPrint class, and on the label, I assigned the visPrint class. When the user prints the form, the label is displayed and the form field is hidden.

    I assume you can do something similar in a non-ASP.NET environment by following the same pattern.

    No scripting required.

提交回复
热议问题