I'm in a somewhat silly problem, I have two section
grid
, which the first one has 4 div
with the property grid-template-columns: 1fr 1fr 1fr 1fr;
and the second section
have 3 div
with the property grid-template-columns: 1fr 2fr 1fr;
ie the center div has 2fr unlike its siblings on the sides with 1fr
. What I need is that the divs of both section are aligned vertically and are of the same size, that is, the div of 1f
are the same ancho
.
Although both section
have the same grid-gap: 20px;
, there still remains a small difference in spacing and size.
I think the problem is in the grid-gap
I'm having, but I'm really confused I do not know how to calculate, to achieve what is necessary.
I appreciate the help.
section{
margin: 0 auto;
width: 500px;
height: 200px;
border: 5px solid #000;
margin-bottom: 10px;
display: grid;
grid-gap: 20px;
}
.section1{
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr;
}
.section2{
grid-template-columns: 1fr 2fr 1fr;
grid-template-rows: 1fr;
}
section > div {
background: #faf;
}
<section class="section1">
<div></div>
<div></div>
<div></div>
<div></div>
</section>
<section class="section2">
<div></div>
<div></div>
<div></div>
</section>