Print when textarea has overflow

前端 未结 11 955
眼角桃花
眼角桃花 2020-12-04 23:59

I have a form with some text areas that allow a scroll bar when the text exceeds the text box. The user would like to be able to print the screen, and this text is not visib

11条回答
  •  旧巷少年郎
    2020-12-05 00:18

    I recently ran into the same issue. My solution was to duplicate the content into form controls for editing and into divs for printing.

    In my Head I put a print stylesheet.

    
    

    In printform.css I put the following

    .screenOnly { display: none; }
    .printOnly { display: inline-block; }
    

    For textareas (and other field types that were causing problems) I used the following code

    
    

    When displayed on screen the textareas are shown and the divs duplicating their content are hidden. When printing the opposite applies.

    I know you already picked an answer to this question but while using the print stylesheet is a good idea it didn't describe a specific solution. Setting overflow:visible on the textarea (my first idea) didn't work so I ended up going with the solution above. If you're still having difficulties I hope this helps you out

提交回复
热议问题