I am working on a very form-heavy web application. I am presented the task to create a report view of the entered data. For the most part it works so far, but I'm having trouble styling the textarea
s in a way that it adjusts to the content length. There needs to be a CSS-based print view of the report page too.
Basically the report page is nothing more than the form page with an added CSS class on the form
tag. The intention is to reuse the form pages with as minimal adjustments as possible to reduce double maintenance cost.
Unfortunately I cannot rely on Javascript as the application is being run in a very sensitive field of business where Javascript is often disabled with nothing the user can do about it.
So use this as a snippet to copy to your answer (if there is any answers not involving Javascript or changing the tag):
textarea {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: #f8f8f8;
border: 0 none;
display: table;
font-family: sans-serif;
height: auto; /* this doesn't work */
margin-bottom: 20px;
padding: 0;
resize: none;
width: 100%;
}
<textarea>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</textarea>
<textarea>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
</textarea>
If you have any relevant reference I'm also willing to accept "not possible without Javascript" as an answer.