Before and: after pseudo-elements

Source: Internet
Author: User

Before and after are the pseudo-elements commonly used in the front-end, in the direct translation of Chinese,

Before represents the previous

After represents the

In CSS, this is probably the case;

The following code:


HTML code

<p class= "box" >this is element</p>

CSS Code

        //before  Chinese translation in front           //after   Chinese translation for after         p.box{             width:500px;             border:solid 1px blue;             padding:20px;        }         p.box:before{             content: ' This is before ';             border:solid 1px pink;             padding:10px;            margin:0 10px  10px 0;         }        p.box:after{             content: "This is after";             //use non-textual content, note that quotation marks cannot be used, otherwise it will be considered as text              //content:url (.. /img/bg.jpg);            width:40px;             height:40px;             border:solid 1px black;             padding:15px;        }

The effect in the browser is as above;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/0B/wKioL1So09nxKC-3AAAutICTKd0498.jpg "title=" 1.png " alt= "Wkiol1so09nxkc-3aaautictkd0498.jpg"/>



Some browsers are not compatible with pseudo elements, such as IE6/7 good for the element is mostly just cosmetic, and does not have much effect on parsing of HTML




Before and: after pseudo-elements

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.