'In grid, what does 2/-2 means?
I have seen someone used grid-column: 1/-1 and he explained that instead to write 1/(the number of the last grid), you simply can use 1/-1 . But then i have seen he also used 2/-2, i thought it means start from grid 2 till the end, but it didnt it has spanned like 2/4. so what does 2/-2 means?
Solution 1:[1]
A self-explanatory example:
.grid {
display:grid;
grid-template-columns:repeat(6,1fr);
grid-gap:10px;
}
i {
background:red;
height:20px;
}
.grid > div {
border:2px solid;
height:50px;
text-align:center;
}
<div class="grid">
<i></i><i></i><i></i><i></i><i></i><i></i>
<div style="grid-column:1/-1">
from the 1st to the last
</div>
<div style="grid-column:2/-2">
from the 2nd to the "before the last"
</div>
<div style="grid-column:3/-3">
from the 3rd to the 3rd starting from the end
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Temani Afif |
