Imagine I have a grid with couple of columns and some gap between them
.my-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 3px;
}
Then I want to place an input
to both cells. But this input has to be styled with some border and so on. It's convenient for me to wrap it in a flex container:
<div class="flex-container">
<input type="text">
</div>
.flex-container {
display: flex;
flex-direction: row;
width: 100%;
border: 1px solid #cc0384;
border-radius: 5px;
padding: 5px;
> input {
flex-grow: 1;
border: none;
outline: none;
}
}
And then I just want to place such inputs into the cells of a grid.
<div class="my-grid">
<div class="flex-container">
<input type="text">
</div>
<div class="flex-container">
<input type="text">
</div>
</div>
I expect that there will be a couple of inputs which are separated by gap. But suddenly they are intersected with each other. It seems that an internal input takes the whole width of grid cell and flex-box containers are spilled over the borders of grid cell. What is the reason and how to fix that?