I know that input elements are made read-only by applying the readonly
boolean attribute, and being an attribute it is not affected by CSS.
On the other hand, my scenario seems to be a very good fit for CSS, so I was hoping there is some kind of a CSS trick to let me do it. I have a printable version hyperlink on my form. Clicking it displays a ... printable version of the document. It is mostly CSS stuff, my print.css looks like this:
html.print {
width: 8.57in;
}
.print body {
font: 9pt/1.5 Arial, sans-serif;
margin: 0 1in;
overflow: auto;
}
.print #header, .print #footer {
display: none;
}
.print .content {
background-color: white;
overflow: auto;
}
.print .fieldset > div.legend:first-child {
background: white;
}
.print ::-webkit-input-placeholder {
/* WebKit browsers */
color: transparent;
}
.print :-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
color: transparent;
}
.print ::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: transparent;
}
.print :-ms-input-placeholder {
/* Internet Explorer 10+ */
color: transparent;
}
.print .check-mark {
display: inline;
}
.print input[type=checkbox] {
display: none;
}
.print .boolean-false {
display: none;
}
There are also a few javascript pieces, such as:
- Adding the
print
class to the html element
- Displaying tables without scroll bars
- A few other minor things, like hiding any popup overlays.
My current problem is input fields. They should be read-only, however, I have no idea how to do it with minimum changes to the code. CSS could be a perfect solution.
Any ideas?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…