If a fieldset
element is set to display: grid
, grid-gap
will not work.
fieldset#grid {
display: grid;
grid-gap: 10px;
box-sizing: border-box;
border: solid red 1px;
}
.child {
padding: 15px;
background: blue;
}
<fieldset id='grid'>
<div class='child'>
<div>gc1</div>
<div>gc2</div>
</div>
<div class='child'>c2</div>
<div class='child'>c3</div>
<div class='child'>c4</div>
<div class='child'>c5</div>
</fieldset>
div#grid {
display: grid;
grid-gap: 10px;
box-sizing: border-box;
border: solid red 1px;
}
.child {
padding: 15px;
background: blue;
}
<div id='grid'>
<div class='child'>
<div>gc1</div>
<div>gc2</div>
</div>
<div class='child'>c2</div>
<div class='child'>c3</div>
<div class='child'>c4</div>
<div class='child'>c5</div>
</div>
You can change the fieldset
to a div
, and everything works fine. Exact same code. The only difference is the element.
Why is this the case?
How can I fix this?