Print Stylesheet - Converting inputs to text

后端 未结 7 448
孤独总比滥情好
孤独总比滥情好 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:14

    If you are using Bootstrap:

    @media print {
      .no-print {
        display: none !important;
      }
    
      .form-control
      {
        border: 0;
        padding:0;
        overflow:visible;
      }
    }
    
    0 讨论(0)
  • 2021-01-02 04:18
    input { border-style: none; display: inline}
    
    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-02 04:23

    I came across this searching for information on how to style my forms and a few other things.

    After messing with some CSS I figured out a CSS only method that works for me.

    My forms all have styling that involved color background and a border that is black.

    In my print CSS file I copied my form css and changed all of the colors (not the text itself) to white. In other words it hides my text box and displays only the text.

    Original CSS - #form textarea, #form input, #form select{ border:1px solid #ffffd; color:#313131; }

    Print CSS - #form textarea, #form input, #form select{ border:1px solid #fff; color:#fff; }

    Works like a charm =>

    Hope this Helps

    0 讨论(0)
  • 2021-01-02 04:28

    To define the width of the input fields in the CSS print section, use:

    width: ?cm 
    

    for the corresponding input elements.

    Tested in Firefox; maybe it wasn't working in previous versions of the browser.

    0 讨论(0)
  • 2021-01-02 04:32

    For bootstrap this works for me. It is based on user5712635s answer but I added the appearance properties to get rid of the down arrows on selection inputs.

    @media print {    
      .form-control
      {
        border: 0;
        padding:0;
        overflow:visible;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
      }
    }
    
    0 讨论(0)
提交回复
热议问题