CSS pseudo-class selector detailed parsing and case use-----pseudo-class selector (2)

Source: Internet
Author: User

  1. struct pseudo-class selector:
    <div>    <ul>                          /*ul:only-of-type*/        <li>one</li>          /*li: First-child   Li:nth-child (2n+1) */        <li>two</li>          /*li:nth-child (2) */        <li>three</li>       /*li:last-child   li:nth-child (2n+1) */    </ul>    <div>adc</div>        /*div div:first-of-type*/    <p>para</p>    <div >def</div>        /*div div:last-of-type*/    <p>para</p>           /*p: Nth-of-type (2) */    <b>ghi<b></div>

    1.e:first-child: Element E as the first child element of a parent element. Equivalent to E:nth-child (1).
    2.e:last-child: An element of the last child element of the parent element E. is equivalent to E:nth-last-child (1).
    3.e:root: Select the root element of the document where the match element E resides.
    4.E F:nth-child (an+b), n takes any positive integer with 0. Select the an+b+1 child element f of the parent element E. That is, the selected element has a sibling node of type An+b F before it.
    5.E F:nth-last-child (), similar to above. From the post-number.
    6:e:nth-of-type (n), select the nth E element within the parent element that has the specified type.
    7:e:nth-last-of-type (n), selects the reciprocal nth E element within the parent element that has the specified type.
    8:e:last-of-type
    9:e:first-of-type
    10:e:only-child, the parent element contains only one child element, and the child element matches E.
    11:e:only-of-type, the selection parent element contains only one child element of the same type, and the child element matches the E
    12:e:empty: Selects an element that has no child elements and does not contain a text node.

  2. Negation pseudo-Class selector:
    E:not (f), matches all E elements except F.


  3. Property selector:
    1.E[ATTR]: Select match E element with attr attribute
    2.e[attr=val]: Select to match the E element with the attr attribute, and the attribute value is Val (val case sensitive).
    3.e[attr|=val]: Select to match the E element with the attr attribute, and the attribute value is Val or begins with Val.
    4.e[attr~=val]: Select match E element with attr attribute, attr attribute value has multiple space-delimited values, and one of the property values is Val.
    5.e[attr*=val]: Select to match the E element with the attr attribute, and the attribute value contains Val at any location.
    6.e[attr^=val]: Select to match the E element with the attr attribute, and the attribute value begins with Val.
    7.e[attr^=val]: Select to match the E element with the attr attribute, and the attribute value ends in Val.

CSS pseudo-class selector detailed parsing and case use-----pseudo-class selector (2)

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.