Writing triangles with CSS

Source: Internet
Author: User

Topic:

Please use CSS to implement the style as shown in the relevant dimensions, where the DOM structure is:
<div id= "Demo" ></div> ideas, 1) Two elements a,b:width with Heigh set to 0 left set to 100% (this requires the parent element of the demo position:relative, and AB Position:absolute) 2) border is set to transparent, then border-left the following element is set to #000 black, the above element is set to # FFF White (The following element border 2px larger than the above) specific code: HTML:
<id= "Demo"></div>

Css:

#demo{width:100px;Height:100px;Background-color:#fff;Border:2px solid #000;position:relative;}#demo: After, #demo: Before{position:Absolute;width:0;Height:0; Left:100%;Border:Solid Transparent;content:"";}#demo: after{Top:20px;Border-width:10px;Border-left-color:#fff;}#demo: Before{Top:18px;Border-width:12px;Border-left-color:#000;}

Writing triangles with CSS

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.