4 ms·
Additionally, you can count from the last grid divider with minus numbers. You can have -1, but I can imagine some pushback against -0.
by jwarren 10y ago
Additionally, you can count from the last grid divider with minus numbers. You can have -1, but I can imagine some pushback against -0.
- ajross 10y agoLots of languages (c.f. python) do negative indexes with the first one starting from zero. The last element is indeed -1, because the element selected is simply the array-size-modulus of the index. It wraps exactly how you expect, and a few tricks use this. CSS grid's negative indexes, hilarious, don't even get this right. If the first element is 1 then the last must be 0, right? No, it's not. Nor is it -1. It's negative two. Don't ask. I don't know.
- jwarren 10y agoYou're not wrong on the first point, but I imagine consistency with the front and back of the index was on the spec designers minds. I do have to point out that your second point is not correct. Remember it's not grid areas, it's grid dividers. So the final grid line <strong>is</strong> in fact -1. See my very hasty little Codepen: https://codepen.io/jodi/pen/ZeNRJZ https://codepen.io/jodi/pen/ZeNRJZ