CSS3 new feature selector (supplemental)

Source: Internet
Author: User

1. Select the first character in the P tag

p:first-letter{

color:red;

font-size:25px;

}

2. Select the first line in the P tab

p:first-line{

color:red;

font-size:25px;

}

3. Add pseudo-classes before and after P

p:before/after{

Content: "';

Setting Property Styles

}

4. set the style of input when it has focus, can be modified, cannot be modified, and is selected

input:focus/enabled/disabled/cheked{

Background:orange;

}

5. Select the first P label in parent

#parent p:first-of-type{

Set style

}

6. Select the P tag that is the only child (without any sibling tags)

#parent p:only-child{

Set style

}

7. Select the second element of the Div, and the second element is the P element (cannot be selected if it does not meet the requirements)

Div p:nth-child{

}

8. Select the nth P element in a div

Div P:nth-of-type (n) {

}

9. Select the first and last elements, and they are P tags

Div p:first/last-child{

}

CSS3 new feature selector (supplemental)

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.