Select last child when odd, 2 last childs when even

后端 未结 3 989
失恋的感觉
失恋的感觉 2020-12-31 14:01

I\'m in a situation where the number of elements showed is variable, and I need a strange solution which I\'m not able to achieve, I even doubt if it\'s achievable only with

3条回答
  •  无人及你
    2020-12-31 14:27

    Absolutely it can be done, with pure CSS. See the complete code below (odd child, last child red; even childs, last 2 childs green)

    
    
    
    
    
    
    
    

    This is one.

    This is two.

    This is three.

    This is four.

    This is five.

    This is six.

    Enjoy, the coding ;)

提交回复
热议问题