CSS Summary 12:css Pseudo-Class (pseudo-classes)

Source: Internet
Author: User

1 Pseudo-class effect : CSS pseudo-class is a special effect used to add some selectors.

2 Common examples:2.1anchor Pseudo-class: code:

Normal syntax:

< Span class= "hl-reserved" > < Span class= "hl-comment" >a{color: #FF0000 ;} /*  text color  */

Pseudo-Class syntax:

A: Link {color:#FF0000;} / * non-visited links * /

< Span class= "hl-comment" >a:visited {color: #00FF00 ;} /* visited link */

< Span class= "hl-reserved" > a:hover {color: #FF00FF ;} /* mouse over link */

< Span class= "hl-reserved" > a:active {color: #0000FF ;} /* selected links */

< Span class= "hl-brackets" > < Span class= "hl-comment" > Note: in the CSS definition, a:hover must be placed after A:link and a:visited to be valid.   in the CSS definition, a:active must be placed after a:hover to be valid. The name of the pseudo-class is not case-sensitive.

2,2 CSS-: first-child pseudo-Class

You can use the: First-child pseudo-class to select the first child element of an element

Note: Prior versions of IE8 must be declared <! Doctype>, this way: First-child can take effect

Example 1: matches the first <p> element: the first label of the P tag is blue.

P: first-child {

color:blue;

}

Example 2: The text in the first label I within the label I within the P tag is blue

p > I: First-child < Span class= "Hl-code" >{

color:blue

}

CSS Summary 12:css Pseudo-Class (pseudo-classes)

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.