A practical hack to make CSS nth- selectors variable within Web Components.
Using CSS variables, at least when I’m writing these lines in June 2021, is not supported in media queries or selector, e.g. :nth-child(var(--my-variable))
does not work.
This is a bit unfortunate but, not unsolvable. In some recent development I bypassed this limitation by injecting style
elements in the DOM, into my Web Components, in order to animate block of codes in DeckDeckGo.
#programming #web-development #web-components #css