Here's a very simple method. You only need three lines of code.
For wide screens:
.footer-inner {
display: grid;
grid-auto-columns: 1fr;
}
.footer-inner > div {
grid-row: 1;
}
/* non-essential demo styles */
.footer-inner { background-color: gray; grid-gap: 1px; }
.footer-inner > div { background-color: lightgreen; text-align: center; padding: 5px;}
<div class="footer-inner">
<div>One</div>
<div>Two</div>
<div>Three</div>
<div>Four</div>
</div>
For narrow screens:
.footer-inner {
display: grid;
grid-auto-columns: 1fr;
}
.footer-inner > div:first-child {
grid-column: span 3;
}
/* non-essential demo styles */
.footer-inner { background-color: gray; grid-gap: 1px; }
.footer-inner > div { background-color: lightgreen; text-align: center; padding: 5px;}
<div class="footer-inner">
<div>One</div>
<div>Two</div>
<div>Three</div>
<div>Four</div>
</div>
Explanations
wide screens
The grid-auto-columns
property sets the width of implicit columns. By setting the value to 1fr
, all columns created will consume an equal distribution of free space in the row. With grid-row: 1
applied to all items they will appear on the first row.
narrow screens
Once you set the first item to span three implicit columns the container must create three columns. The remaining items can then fit neatly underneath in the newly-created columns.
Lastly, consider using fr
units instead of percentages (like 33.33%) in your track sizing. Then you don't have to worry about factoring in margins and grid gaps. Here's some more info: The difference between percentage and fr units in CSS Grid Layout