Is it possible to select the last n items with nth-child?

前端 未结 5 2237
猫巷女王i
猫巷女王i 2020-12-02 09:04

Using a standard list, I\'m trying to select the last 2 list items. I\'ve various permutations of An+B but nothing seems to select the last 2:

l         


        
5条回答
  •  北海茫月
    2020-12-02 09:19

    Because of the definition of the semantics of nth-child, I don't see how this is possible without including the length of the list of elements involved. The point of the semantics is to allow segregation of a bunch of child elements into repeating groups (edit - thanks BoltClock) or into a first part of some fixed length, followed by "the rest". You sort-of want the opposite of that, which is what nth-last-child gives you.

提交回复
热议问题