Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-grid] span count starts only on explicit grid? #4705

Closed
nonopolarity opened this issue Jan 27, 2020 · 13 comments
Closed

[css-grid] span count starts only on explicit grid? #4705

nonopolarity opened this issue Jan 27, 2020 · 13 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-grid-1

Comments

@nonopolarity
Copy link

about span counting, was it not counting start at implicit grid line but the spec changed and now it start at implicit grid line?  Or was it a terminology confusion -- could you add comments to this issue?

I can't find the related specs details on this topic.

https://stackoverflow.com/questions/59919727/in-css-grid-layout-do-we-count-the-span-even-starting-on-implicit-grid-lines

@Loirooriol
Copy link
Contributor

See https://drafts.csswg.org/css-grid/#explicit-grids

Numeric indexes in the grid-placement properties count from the edges of the explicit grid.

Otherwise the definition of the implicit grid would be circular, since it depends on the position of the grid items, which would depend on the implicit grid.

@nonopolarity
Copy link
Author

nonopolarity commented Jan 27, 2020

that's about the "indexes"... what about the span counting? Can it start on implicit grid or explicit grid?

Wait a second, does this whole thing just mean, we refer to the explicit grid for the numbering (everything relative to the original explicit grid), and never refer to the implicit grid, as it is a new coordinate system? That's all it means?

(and do we ever refer to the implicit grid anyway? I think the coordinate system of the explicit grid and implicit grid are the same, unless if the implicit grid extended some grid lines either to the left or to the top of the explicit grid... in which case we can say the coordinate system shifted. But if we never use the implicit grid coordinate system ever, why bring it up? Why not just say everything is relative to the original explicit grid, and that's simple and clear?)

@Loirooriol
Copy link
Contributor

Not sure what you mean. If you use grid-row: 2 / 4, then the grid area will go from the 2nd row line (in the explicit grid) to the 4th row line (in the explicit grid). The grid span is the number of occupied tracks, 4-2=2 rows in that example. It's not a location that can be defined with respect to the explicit or implicit grid.

If you use grid-row: span 2 / 1, then the item will span 2 rows and the area will end at the 1st explicit row line. So the item will occupy 2 implicit rows.

@nonopolarity
Copy link
Author

It is about:

https://stackoverflow.com/questions/59919727/in-css-grid-layout-do-we-count-the-span-even-starting-on-implicit-grid-lines

This question is about whether CSS grid "span counting" -- whether it should start on implicit grid line. In CSS Definitive Guide, 4th Ed, p. 695, it is said that

box4 is where things really get interesting. It ends on the fifth row line, which is to say the second implicit grid line. It spans back three lines—and yet, it still starts on the same grid line as box3. This happens because spans have to start counting within the explicit grid. Once they start, they can continue on into the implicit grid (as happened with box2), but they cannot start counting within the implicit grid.

Is it true? Or has there been a spec change? Can "span counting" start within implicit grid?

@Loirooriol
Copy link
Contributor

If you have

#grid { grid-template-rows: 2em 2em }
.box04 { grid-row: span 2 / 5 }

Then the item is placed in a grid area that ends at the 5th row line (you start counting at the beginning of the explicit grid) and spans two rows backwards. That is, from line 3 to line 5. The line 3 just happens to be the end of the explicit grid, but this is not relevant here.

So basically positive indexes count forwards from the start of the explicit grid, and negative indices count backwards from the end of the explicit grid. They may end up referring to implicit lines, but they are referred to with respect to the explicit grid.

@nonopolarity
Copy link
Author

so related to the .box04

if it is span 4 / 5

according to CSS Definitive Guide 4th Ed, we don't count the span starting on the implicit grid (line), but that we have to count starting from explicit grid (line), so we can't count it starting from line 5 but have to count it from line 3.

But the reality is that it seems to count from line 5.

@Loirooriol
Copy link
Contributor

span 4 / 5 is just like 1 / 5. And you find the 1st and 5th lines by counting from the beginning of the explicit grid.

@nonopolarity
Copy link
Author

nonopolarity commented Jan 28, 2020

span 4 / 5 is just like 1 / 5. And you find the 1st and 5th lines by counting from the beginning of the explicit grid.

shouldn't the logic be, you start at line 5 and count from line 5 for 4 steps? This is the most original definition. It can't be translated to form A if person A prefers it one way, and translated to form B if person B prefers it the other way: "it is the same as 1 / 5 and you start the counting from line 1". The key here is "where to start the counting" and you can't randomly choose to start counting at line 5 or line 1 as you want.

@Loirooriol
Copy link
Contributor

With span 4 / 5, https://drafts.csswg.org/css-grid/#line-placement is clear that

  • The end line is the 5th from the start of the explicit grid
  • The start line is 4 lines before the end line. That is, the 1st one from the start of the explicit grid.

So can you point out where's the problem? We are just going in circles.

@nonopolarity
Copy link
Author

nonopolarity commented Jan 28, 2020

With span 4 / 5, https://drafts.csswg.org/css-grid/#line-placement is clear that

  • The end line is the 5th from the start of the explicit grid
  • The start line is 4 lines before the end line. That is, the 1st one from the start of the explicit grid.

So can you point out where's the problem? We are just going in circles.

You do know that, in computer science, when we do for (i = 5; i >= 1; i--) it is not the same as for (i = 1; i <= 5; i++)

Besides, in that code sample for box04, if I change it to grid-row: span 6 / 5; it again is starting the counting on implicit grid line even if you want to start the counting from the lowest number. So no matter how you look at it, the count starts at implicit grid, when the rule supposed stated "the counting has to start on explicit grid"

@tabatkins
Copy link
Member

@Loirooriol is exactly correct in their answers here.

In span 4 / 5, the span part just tells you how far apart the start and end lines will be. Whether the other number tells you the box will start or end on the provided line depends on whether it's the first or second value; in this case 5 is the second value, telling you that the grid item will end on line 5, and so it'll start 4 lines earlier (line 1) .

If you reversed the values to 5 / span 4, it would instead start on line 5, and then count 4 lines forward, ending on line 9.

I'm going to go ahead and close this issue, as your question has been answered.

@tabatkins tabatkins added Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-grid-1 labels Jan 28, 2020
@nonopolarity
Copy link
Author

nonopolarity commented Jan 29, 2020

@tabatkins that really isn't what the question is. THE QUESTION IS: THERE SEEMS TO BE A RULE THAT SAYS COUNTING OF SPAN MUST START ON EXPLICIT GRID (EXPLICIT GRID LINE) (as in CSS Definitive Guide 4th Ed), but I don't see it actually happening. So I am wondering if this rule has been obsolete or what the real situation is?

@tabatkins
Copy link
Member

There is no such rule and never has been. I've never read "CSS Definitive Guide 4th Ed" and can't comment about what it may or may not say. I and Oriol have explained how lines and spans work; I encourage reading the spec to understand more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-grid-1
Projects
None yet
Development

No branches or pull requests

3 participants