html - how to pick second element starting from the last one? -


enter image description here

i have 2 elements , have same class , want pick second element starting last one. ( hope image tells everything)

i tried nth-child 2 elements have same class why can't nth-child idea ?

you can use nth-last-child(2) or nth-last-of-type(2), select 2nd last item.

li {    display: inline-block  }  li:nth-last-child(2) {    color: red  }
<ul>    <li>test</li>    <li>test</li>    <li>test</li>    <li>test</li>    <li>test</li>  </ul>  <hr />  <ul>    <li>test</li>    <li>test</li>    <li>test</li>    <li>test</li>    <li>test</li>    <li>test</li>    <li>test</li>  </ul>


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -