Use:: befor and:: After pseudo elements to add icons to a Web site

Source: Internet
Author: User

CSS3 in order to distinguish between pseudo-classes and pseudo-elements, pseudo-elements are written with double colons.

Common Pseudo-Class--:hover,:link,:active,:target,:not (),: Focus.

Common pseudo-element--::first-letter,::first-line,::before,::after,::selection.

:: Before and:: After-specific content, used in CSS rendering to add to the head or tail of the element's logic.

These additions do not appear in the DOM, do not change the contents of the document, are not duplicated, but are only added to the CSS render layer.

So do not use: Before or: After show meaningful content, use them as much as possible to display the cosmetic content, the example of the mark.

Example: the website some contact phone, want to add an icon before them, you can use: before pseudo-element, as follows:

<!DOCTYPE HTML><MetaCharSet= "Utf-8" /><styletype= "Text/css">. Phonenumber::before{content:' \260e ';font-size:15px;}</style><Pclass= "PhoneNumber">12345645654</P>

The Html,js and CSS of these special characters are different.

Use:: befor and:: After pseudo elements to add icons to a Web site

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.