I have seven items loaded. I am going to write the logic such that if I hide the items, the other items should align to the screen automatically
For example,
if the task is removed(hidden) the item1, item2, item3, item 4,and the other item should align to the screen and vice versa
.grid-container {
display: grid;
padding: 77px 88px 0 88px;
background-color: #F4F4F4;
grid-template-columns: 624px repeat(2, 304px);
grid-template-rows: auto repeat(2, 1fr) fr;
justify-content: center;
align-items: center;
gap: 1rem;
}
.tasks {
grid-column: 1/2;
grid-row: 1/3;
}
.t1 {
grid-column: 2/3;
grid-row: 1/2;
}
.t2 {
grid-column: 3/4;
grid-row: 1/2;
}
.t3 {
grid-column: 2/3;
grid-row: 2/3;
}
.t4 {
grid-column: 3/4;
grid-row: 2/3;
}
.otherItems {
grid-column: 1/4;
grid-row: 3/4;
}
<div class="grid-container">
<div class="task">Task</div>
<div class="t1">1</div>
<div class="t2">2</div>
<div class="t3">3</div>
<div class="t4">4</div>
<div class="otheritems">other items</div>
</div>
2
Answers
You can use the align-items property on the grid container, to align the items using one of the following values: like
auto.
normal.
start.
end.
center.
Do not set columns and rows to the items, just let the grid place them