1

Is it possible to find the number of siblings an element has to use in CSS calc?

This stems from this question/answer where the solution works in Chrome but not in Firefox.

We can do various calculations using calc (taking into consideration the parent's styles, various variables, and simple arithmetic).

I'm hoping to do something along the lines of grid-row-start: span calc(numSiblings); but I'm not certain it's possible to retrieve the number of siblings an element has using CSS.

I've seen this question which does the styling based on the explicit number of siblings, and I'm hoping there's a possibility for a more dynamic version.

Community
  • 1
  • 1
Hodrobond
  • 1,665
  • 17
  • 18
  • No, that you can't do with CSS (yet) – Asons May 18 '17 at 17:32
  • If you share what you actually try to achieve there might be another solution than using calc, e.g. setting the second parameter to a very high number might already be a workaround. – Marvin May 18 '17 at 18:26
  • @Marvin This was definitely a "hack-workaround", in [this question](http://stackoverflow.com/questions/44052336/make-css-grid-item-span-from-first-to-last-row/44052563#44052563) we were trying to have a specific child of a `grid` span through all the rows. There is an answer for an explicit number, but not an implicit one. – Hodrobond May 18 '17 at 18:31
  • Oh I'm sorry. I somehow haven't noticed this link/sentence in your text. – Marvin May 18 '17 at 19:45

0 Answers0