I'm fairly new to CSS grid. I made a simple contact form to experiment with the system. My grid has 2 columns and 5 rows. I placed 4 inputs in the left column, 1 textarea in the right column and one last input in the last row. The textarea can be resized vertically.
The problem is that dragging the textarea downward resizes all the rows in the grid, including rows in adjacent columns, consequently changing the overall layout (see snippet example below). It seems to be a normal and logical behavior to me but I was wondering if there's any way to stop rows in other columns from resizing using grid directly.
* {
box-sizing: border-box;
}
html, body, input, textarea {
padding: 0;
margin: 0;
}
.form {
margin: 10px;
display: grid;
grid-template: repeat(5, auto) / 4fr 6fr;
grid-gap: 10px;
grid-template-areas:
". textarea"
". textarea"
". textarea"
". textarea"
"submit submit";
}
.input, .submit {
height: 30px;
}
.submit {
grid-area: submit;
}
.textarea {
grid-area: textarea;
resize: vertical;
min-height: 150px;
}
<form class="form">
<input class="input" type="text" />
<input class="input" type="text" />
<input class="input" type="text" />
<input class="input" type="text" />
<textarea class="textarea" name="message"></textarea>
<input class="submit" type="submit" />
</form>
So far the most straightforward solution I've found to get around this issue is to wrap the first 4 inputs inside a div (say with class="container") and set a fixed height to it, like so:
.container {
grid-area: container;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 150px;
}
It works but I don't find it very convenient.
Is there any work around to this problem using grid directly?

