I am using CSS Grid (12 columns) with inputs fields. Due to the way I am creating the form (the form design is in JSON and created on the fly) the input fields are not the direct children of the grid but are wrapped in a div. If I do a grid-column: span of the div I also want the input field to span the columns - but not over the grid-gap. I have tried multiple ways of doing this and the best seems to be width: 100% on the input BUT this ignores the grid gap. Any idea as to how I can get the input field to be the same width as the div?
Sorry if I explained it badly - here is a screenshot of what I mean:
here the code:
.container {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-gap: 20px;
background-color: black;
}
.fill-width {
width: 100%;
}
.width-4 {
grid-column: span 4;
}
<div class="container">
<input id="field1" class="width-4" placeholder="field1 (4)" />
<input id="field2" class="width-4" placeholder="field2 (4)" />
<input id="field3" class="width-4" placeholder="field3 (4)" />
<div class="width-4">
<input id="field5" placeholder="field5 (4)" />
</div>
<input id="field6" class="width-4" placeholder="field6 (4)" />
<input id="field7" class="width-4" placeholder="field7 (4)" />
<div class="width-4">
<input id="field1" class="fill-width" placeholder="field1 (4)" />
</div>
<div class="width-4">
<input id="field2" class="fill-width" placeholder="field2 (4)" />
</div>
<div class="width-4">
<input id="field3" class="fill-width" placeholder="field3 (4)" />
</div>
</div>
and the codepen example: https://codepen.io/ursus_the_bear/pen/mdRQNXM
