Css3:nth-child () Selector

Source: Internet
Author: User

Review and consolidate the use of CSS3 's Nth-child (). 2015-10-20

1 definitions on the world of:

: The Nth-child (n) selector matches the nth child element that belongs to its parent element, regardless of the type of the element.

n can be a number, a keyword, or a formula.

2 usage examples

A is used to process a specific child element of an element,

For example, P:bth-child (3) {color:red;} means that the 3rd child element of the P element is set to a red font.

b for interlaced discoloration

Odd and even are keywords that can be used to match sub-elements with an odd or even number subscript (the subscript for the first child element is 1).

  

C Use the formula (an + b). Description: Indicates the length of the period, N is the counter (starting at 0), and B is the offset value

  

Indicates setting 1,3,5 ... cardinal item color is red

3 jquery selector: Nth-child (even) and: difference of even

A using nth-child (even)

Page effect: 1-even line background is red

b Use: Even

Page Effect: 0-even line background is red

Css3:nth-child () Selector

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.