DEV Community

Discussion on: CSS --var: inherit(--var) + 2; Yes, you can! Without JS!

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

Nice writeup. I haven't used less in years, it is nice to see some preprocessor content.

A simpler, pure css way of Odd and Even would be :nth-child(2n+1) :nth-child(2n+2).
Ideally, simple 2n should work for even rows but 2n+2 has been quite popular due to some reason I don't know about.

W3.org article on even-odd uses col:first-child col:nth-child(2n+3) it still works as expected and I have used it a few times in project.

Collapse
 
janeori profile image
Jane Ori

Unfortunately those are even odd sibling selectors, inherit() needs even odd depth selectors, so it's a little bit more work. Thank you for checking it out though!

Some comments have been hidden by the post's author - find out more