Css before and after pseudo-element applications, cssbeforeafter pseudo

Source: Internet
Author: User

Css before and after pseudo-element applications, cssbeforeafter pseudo

1. Description

": Before" A pseudo element can insert new content before the element content.

": After" a pseudo element can insert new content after the element content.

2. Compatibility

Pseudo elements can be written in two ways,Single colon and double colon, Single colon and double colonThe role is the same.

Compatibility View: http://caniuse.com/#search=%3Abefore

As you can see, the IE 8 browser only supports single-colon writing and does not support double-colon writing. ThereforeWe recommend that you use a colon to write the before and after pseudo elements..

3. Applications

(1) Clear floating

 

.clearfix:after {    content: " ";    display: table;}.clearfix:after {    clear: both;}

 

(2) Add beautification icons

For example, clear ul li to display the default small black spots and add beautifying symbols.

<! DOCTYPE html> 

Effect:

Note:Set the pseudo element to a block-level element. The pseudo element also has the concept of a box model..

 

Related Article

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.