I have a grid layout of, let's say 2 rows, 2 columns in the 1st row, 3 columns in the 2nd row. And a grid gap of 10px between them. It is no problem to give every single grid a background-image. But what if I want them all to have the same background image that starts at the top left grid and continues/is spanned until the bottom right grid. One big background-image over all grids, just separated by the white grid gaps.
html,
body {
height: 100%;
}
.grid {
display: grid;
height: 100%;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: repeat(2, 1fr);
grid-gap: 10px;
}
.grid_cell_one {
grid-column: 1 / span 3;
grid-row: 1 / span 1;
background-image: url("https://cdn.pixabay.com/photo/2017/01/08/21/11/wood-1963988__340.jpg");
}
.grid_cell_two {
grid-column: 4 / span 3;
grid-row: 1 / span 1;
background-image: url("https://cdn.pixabay.com/photo/2017/01/08/21/11/wood-1963988__340.jpg");
}
.grid_cell_three {
grid-column: 1 / span 2;
grid-row: 2 / span 1;
background-image: url("https://cdn.pixabay.com/photo/2017/01/08/21/11/wood-1963988__340.jpg");
}
.grid_cell_four {
grid-column: 3 / span 2;
grid-row: 2 / span 1;
background-image: url("https://cdn.pixabay.com/photo/2017/01/08/21/11/wood-1963988__340.jpg");
}
.grid_cell_five {
grid-column: 5 / span 2;
grid-row: 2 / span 1;
background-image: url("https://cdn.pixabay.com/photo/2017/01/08/21/11/wood-1963988__340.jpg");
}
<div class="grid">
<div class="grid_cell_one">
</div>
<div class="grid_cell_two">
</div>
<div class="grid_cell_three">
</div>
<div class="grid_cell_four">
</div>
<div class="grid_cell_five">
</div>
</div>