Application of CSS selector Nth-child () and Nth-of-type ()

Source: Internet
Author: User

1 <style>2 . table-striped tbody > Tr:nth-child (Odd) > td,. table-striped tbody > Tr:nth-child (odd) > th{3 Background-color:#f9f9f9;4}5         /*Nth-child (): Specifies the background color of each p belonging to the second child element of its parent element;6 nth-child (n): The selector matches the nth child element that belongs to its parent element, regardless of the type of the element, n can make a number, a keyword, or an expression7 odd and even are keywords that can be used to match sub-elements with an odd or even number subscript8 9 Nth-of-type (n): The selector matches each element of the nth child element of a particular type belonging to the parent element, n can make a number, a keyword, or an expressionTen  One difference: nth-child (), the selector selects the nth child element of the parent element, regardless of type A             */ - </style> -  the  - <div style= "margin-top:100px;" > - <table class= "table-striped" > - <tbody> + <tr> - <td>1</td> + <td>dafsdf</td> A </tr> at <tr> - <td>2</td> - <td>QQQQQQQQQ</td> - </tr> - <tr> - <td>3</td> in <td>sssssssssssss</td> - </tr> to <tr> + <td>4</td> - <td>zzzzzzzzzzzzz</td> the </tr> * </tbody> $ </table>Panax Notoginseng  - </div>

Application of CSS selector Nth-child () and Nth-of-type ()

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.