CSS3---Structural pseudo-class selector-nth-last-child (n)

Source: Internet
Author: User
Structural pseudo-Class selector-nth-last-child (n)

": Nth-last-child (N)" selector and the previous ": Nth-child (N)" selector is very similar, but here is a "last", the role of the ": Nth-child (n)" selector differs, Select a specific element by starting the calculation from the last child element of a parent element.

Case Demo

Select the bottom Fifth list item in the list to set its background to orange.

HTML code:

<ol>  <li>item1</li>  <li>item2</li>  <li>item3</li>  <li>item4</li>  <li>item5</li>  <li>item6</li>  <li>item7 </li>  <li>item8</li>  <li>item9</li>  <li>item10</li>  <li>item11</li>  <li>item12</li>  <li>item13</li>  < Li>item14</li>  <li>item15</li></ol>?

CSS code:

Ol > Li:nth-last-child (5) {  background:orange;}

Demo Result:

CSS3---Structural pseudo-class selector-nth-last-child (n)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.