CSS pseudo elements before and after

Source: Internet
Author: User

Today, we found that before and after are used in many foreign websites and framework designs, which were rarely used before. I tried them today and found it interesting ~ Description 1.: before AND: after will insert additional elements before and after the content element;: before will "add" an element before the content and: after, an element is added after the content. We can use the content attribute to add content among them. 2.: before AND: after are released on CSS2.1. after the revision in css3, the pseudo elements are:, and the pseudo classes are:. Therefore, the format is: before,: after 3. both single quotation marks and double quotation marks can be recognized by browsers. However, IE8 only supports the single colon format. Therefore, it is a simple example of compatibility or single colon. div1: before {content: open-quote ;}. div1: after {content: close-quote;} <div class = "div1"> Today is a wonderful day. wish you happy ~ </Div> Result: "Today is a wonderful day. Wish you happy ~" Set the pseudo element style eg1 :. div1 {width: 500px; height: 200px; margin: 100px auto; background-color: # F0F0F0; line-height: 200px; text-align: center ;}. div1: before {content: open-quote; position: relative; font-size: 24pt; line-height: 200px; text-align: center; color: # fff; background: # ddd; border-radius: 25px ;}. div1: after {content: close-quote; position: relative; font-size: 24pt; background: # ddd; border-radius: 25px; li Ne-height: 200px; text-align: center; color: # fff ;}< div class = "div1"> Today is a wonderful day. Wish you happy ~ </Div> result: Note: in actual use, extract the same css. div [class * = '']: before, div [class * ='']: after eg2: (used in combination with pseudo classes) Add a style :. div1: hover: after ,. div1: hover: before {background-color: #555 ;}

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.