About CSS pseudo-class selectors

Source: Internet
Author: User

Common pseudo-classes (pseudo-classes) and pseudo-elements (pseudo-elements)

Pseudo-Class:: Hover mouse on the effect

: Actiive effect after click

Pseudo element

: Before

: After

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title>    <styletype= "Text/css">        *{margin:0;padding:0;        }ul{width:1000px;margin:0 Auto;Counter-reset:Li;        }Li{List-style:None;        }Ul>li{Background-color:#ccc;Margin-top:10px;        }Ul>li:before{content:counter (LI);counter-increment:Li;Background-color:#333;Border-radius:100%;padding:0 5px;Color:#fff;Margin-right:10px;        }. Test{width:200px;Height:200px;background:#000;Color:#fff;        }. Test:before{content: " ";Color:Red;width:20px;Height:20px;background:#fff;float: Left;        }. Test:after{content:" ";Color:Green;width:20px;Height:20px;background:#fff;float: Right;        }    </style></Head><Body><Divclass= "Test">hhhkjkkj</Div><ul>    <Li>List Item One</Li>    <Li>The second item on the list</Li>    <Li>Number three is a bit longer, with some Lorem ipsum for good measure. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqu A. Ut enim ad minim veniam, quis nostrud exercitation Ullamco laboris nisi Ut aliquip ex ea commodo consequat. Duis aute irure dolor in Reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur Sint Occaecat Cupidatat non proident, sunt in culpa qui officia deserunt mollit anim ID est laborum.</Li>    <Li>And here are number four.</Li>    <Li>The fifth item on the list</Li>    <Li>The sixth item on the list</Li></ul></Body></HTML>

Clear float:

. clearfix{zoom:1;}     . Clearfix:after {clear:both;content: '. '; Display:block;width:0;height:0;visibility:hidden;}

About CSS pseudo-class selectors

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.