CSS before and after pseudo element application

Source: Internet
Author: User

1. Description

": Before" pseudo-element can insert new content in front of the content of the element.

The ": after" pseudo-element can insert new content after the element's contents.

2. Compatibility

There are 2 types of pseudo-elements, single colon and double colon , single colon and double colon Act the same .

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

From See: IE8 the browser only supports single colon notation and does not support double colon notation, so it is recommended that before and after pseudo elements be written in a single colon.

3. Application

(1) Clear floating

{    content: "";     display: table;}  {    clear: both;}

(2) Add landscaping icons

such as clear UL li display default small black dot, add beautify the symbol

<!DOCTYPE HTML><HTMLLang= "zh">    <Head>        <MetaCharSet= "UTF-8" />        <title>CSS pseudo-Element application--Add Beautify icon</title>        <styletype= "Text/css">            * {padding:0;margin:0;font-size:14px;            }ul{margin:100px;List-style:None;            }Li:before{Display:Inline-block;content: "";width:4px;Height:4px;background:#0e337a;position:relative; Left:0;Top:-3px;Margin-right:5px;            }        </style>    </Head>    <Body>        <ul>            <Li>1, before pseudo-element use</Li>            <Li>2. After pseudo element use</Li>        </ul>    </Body></HTML>

Effect:

Description: sets the pseudo element to the block-level element, and the pseudo-element also has the concept of a box model .

CSS before and after pseudo element application

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.