Understanding Grid
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
.container:first-child.container > div:first-child.container > div:nth-of-type(2) {
grid-column: 7 / 13;
}span {number of cells}<div cell-span="3">div{
grid-column: span attr(cell-span)
}span-1span-12.container > div:nth-of-type(1),
.container > div:nth-of-type(2) {
grid-column: span 6
}.container {
display: grid;
gap: 2rem;
grid-template-columns: repeat(12, 1fr);
}
.container div {
grid-column: span var(--span)
}<div class="container">
<div style="--span: 6">This is column 1 of 2</div>
<div style="--span: 6">This is another column 1 of 2</div>
<div style="--span: 4">This is column 1 of 3</div>
<div style="--span: 4">This is another column 1 of 3</div>
<div style="--span: 4">This is yet another column 1 of 3</div>
<div style="--span: 4">This is column 1 of 3</div>
<div style="--span: 8">This is column 2 of 3</div>
<div style="--span: 3">This is column 1 of 4</div>
<div style="--span: 3">This is another column 1 of 4</div>
<div style="--span: 3">This is yet another column 1 of 4</div>
<div style="--span: 3">This is one more column 1 of 4</div>
<div style="--span: 3">This is column 1 of 4</div>
<div style="--span: 3">This is another column 1 of 4</div>
<div style="--span: 6">This is column 2 of 4</div>
</div>.container {
$columns: 12;
display: grid;
gap: 2rem;
grid-template-columns: repeat( #{$columns}, 1fr);
@for $i from 1 through $columns {
.span-#{$i} {
grid-column: span #{$i}
}
}
}