Examples of corner triangles implemented by css (no image)

Source: Internet
Author: User

The following figure shows the effect.

 


Triangle direction "width: 0 ",
The reverse direction is the triangle height (20) "border-width: 20px ",
The reverse color is the triangle color "border-color: # eee ",
Add the other two directions to the triangle width (30) "border-width: 15px"
CSS:

The code is as follows: Copy code

Span {
Position: absolute;
Width: 0;
Height: 0;
Border-width: 0 15px 20px 15px;
Border-style: solid;
Border-color: transparent # eee transparent;
Top:-20px;
Left: 50%;
Margin-left:-15px;
}

Example

The code is as follows: Copy code

<! DOCTYPE html>
<Html> www.111cn.net
<Head>
<Title> Arbitrary triangle </title>
<Style>
Div {
Width: 200px;
Height: 60px;
Background-color: # eee;
Position: absolute;
Left: 50%;
Margin-left:-150px;
Margin-top:-50px;
Top: 50%;
Border-radius: 10px;
Float: left;
Font: 12px/20px "";
Color: #000;
Padding: 20px 50px;
        }
Span {
Position: absolute;
Top:-20px;
Width: 0;
Height: 0;
Border-width: 0 15px 20px 15px;
Border-style: solid;
Border-color: transparent # eee transparent;
Left: 50%;
Margin-left:-15px;
} Www.111cn.net
</Style>
</Head>
<Body>
<Div>
<Span> </span>
The opposite direction of the triangle is "width: 0". The opposite direction is the triangle height. The color is the triangle color. The other two directions are added to the width.
</Div>
</Body>
</Html>

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.