Spanning Columns in CSS Grids
Similarly, you can span columns using the grid-column
property.
Let's say we have a grid with four elements. Now let's make the first, second, and third elements appear in the first row. And the fourth element takes up the entire second row:
<div id="parent">
<div id="elem1">1</div>
<div id="elem2">2</div>
<div id="elem3">3</div>
<div id="elem4">4</div>
</div>
#parent {
display: grid;
padding: 10px;
border: 2px solid #696989;
width: 400px;
height: 300px;
}
#parent > div {
padding: 10px;
border: 1px solid #696989;
}
#elem1 {
grid-column: 1 / 2;
}
#elem2 {
grid-column: 2 / 3;
}
#elem3 {
grid-column: 3 / 4;
}
#elem4 {
grid-column: 1 / 4;
}
:
Place all the elements and merge the columns according to the following example:
Place all the elements and merge the columns according to the following example:
Place all the elements and merge the columns according to the following example: