Removing input placeholder on a printable version of an html page

前端 未结 2 1022
萌比男神i
萌比男神i 2020-12-17 16:06

I have a form with input fields. Each input field has a placeholder attribute. There is also a link displaying the printable version of the same form.

My problem is

相关标签:
2条回答
  • 2020-12-17 16:38

    In most modern browsers, you should be able to hide placeholders when printing, via some non-standard CSS selectors.

    @media print {
      ::-webkit-input-placeholder { /* WebKit browsers */
          color: transparent;
      }
      :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
          color: transparent;
      }
      ::-moz-placeholder { /* Mozilla Firefox 19+ */
          color: transparent;
      }
      :-ms-input-placeholder { /* Internet Explorer 10+ */
          color: transparent;
      }
    }
    

    (or color: white, etc.)

    Selector list stolen from: Change an HTML5 input's placeholder color with CSS

    0 讨论(0)
  • 2020-12-17 16:48

    or you can move it outside the visible area of the parent element by text-indent or some other overflowy hack

    0 讨论(0)
提交回复
热议问题