Hi all, in this article I am going share with you a styling elements based on sibling count. Basic idea behind is to count elements sibling and child. As in my previous post I have shared Rotating Words with CSS Animations and Awesome Subtle Click Feedback Effects this is appreciate by you guys a lot.
before going any breif i will let you know out previous most popular article so that you can get benifit from them too which is Rotating Words with CSS Animations and Awesome Subtle Click Feedback Effects.
Lets start, follow the code given below
It is just based on the relations inbetween :nth-child and :nth-last-child. As we can see , the number of total rules is O(N) and the number of selectors is every rule is also O(N).
However, what you really want, is to just target the first element. The others can be targeted with just a sibling selector. With my improvement, the number of total rules is still O(N), but the number of selectors in every rule becomes just 2, making this trick practical for far larger numbers of children:
And here’s a out to prove it:
Yes, I know that following Flexbox and the choice layout modules, techniques such as these are soon becoming primeval, but I think they are yet useful right now.
Im as well as aware that you can emulate this particular example taking into consideration table display modes, but a) Table display modes have additional implications that are sometimes undesirable and b) Widths are just an example, you could come taking place taking into account accessory ways to style the elements based in excuse to their quantity adjoin, which cant be emulated by CSS tables.
How it works:
Markup code :
if you like this solution, please like and share it