I’m trying to make a grid template, but I’m obviously making a mistake somewhere. I need help how to make between box 1 and box 2 stand box 3 for mobile devices or when resize the window.
Thanks!
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(3, 1fr);
padding: 1rem;
gap: 1rem;
}
.grid-item {
padding: 1rem 3rem;
font-size: 1.2rem;
font-family: cursive;
color: #e6c037;
background-color: #784367;
text-align: center;
}
.item-1 {
grid-row: 1 / 3;
grid-column: 1 / 3;
}
.item-2 {
grid-column: 1 / 3;
}
.item-3 {
grid-row: 1 / 3;
grid-column: 3 / 4;
}
```
<div class="grid-container">
<div class="grid-item item-1">Box Оne</div>
<div class="grid-item item-2">Box Two</div>
<div class="grid-item item-3">Box Three</div>
</div>
2
Answers
I’m not sure it answers exactly to your question (some others layout possibilities could be done here)… but it’ll give you some tracks
You can make this work using line-based placement, which is the method you’re using in your code (i.e.,
grid-row: 1 / 3
, etc.). But the lines of code add up when programming for desktop, tablet and mobile.Instead, keep it simple and easy with Grid Areas.
jsFiddle demo