Currently
I have a table row that contains a textarea for user input. The purpose of textarea is so user can input multiple lines.
Code:
table {
border-collapse: collapse;
width: 100%;
border: 1px solid black;
}
th, td {
text-align: center;
border: 1px solid black;
padding: 10px;
}
.container {
border: 1px solid blue;
}
.text-area {
width: 100%;
box-sizing: border-box;
display: flex;
}
.fixed-min {
min-width: 600px;
}
<!DOCTYPE html>
<html>
<body>
<table>
<tbody>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
<tr>
<td>
<div class="container fixed-min">
<textarea class="text-area">Set width in this big column
</textarea>
</div>
</td>
<td>
<div class="container">
<textarea class="text-area">This contents of this column should always be visible i.e. no scroll bar, and instead the height of this row should adjust to show all content.
</textarea>
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>
https://jsfiddle.net/to45asgy/1/
Problem
I would like the textarea to show all content by auto-adjusting height rather than requiring the user to scroll.
Notes:
- I saw a solution on Creating a textarea with auto-resize, but there has to be a simpler solution through CSS that I am missing.
- I used to use an editable rather than before, but because I am using this html within a react component, there were other complications with using an editable so I switched to a . I wanted to know if there is a solution, but appreciate it if there is not, and will then refactor the code to use once more.
EDIT: Seems there is no CSS only solution for :'(