Three ways to make triangles with CSS pseudo-class

Source: Internet
Author: User

On the phone when writing a triangle, I generally use pseudo-class, just the beginning of the use of the picture, but in the current cell phone HD screen, the picture is easy to distort, or use pseudo-class bar!

The first kind: a 90-degree ">" with only lines. (You can do the arrow of a drop-down box, etc.) for example:

. next:after
{
Content: "";
width:6px;
height:6px;
border-left:1px solid #666;
border-bottom:1px solid #666;
Transform:rotate (225DEG);
-webkit-transform:rotate (225DEG);
Position:absolute;
right:9px;
top:20px;
}

The second type: colored. For example:

. next:after
{

Position:absolute;
BORDER-LEFT:9PX solid Transparent;
BORDER-RIGHT:9PX solid Transparent;
BORDER-BOTTOM:9PX solid #f5f5f5;
Content: "";
Display:block;
width:0;
height:0;
Top: -8px;
left:20px;

}

The third type: line + color. Principle, overlapping with two pseudo-classes of different colors.

For example:

. pos_rel {
position:relative;
_line-height:0;
}

. Pos_rel. Icon1 {
Display:block;
BORDER-WIDTH:9PX 9px 9px 0;
Border-color:transparent #1c7ecf Transparent transparent;
Border-style:solid;
Position:absolute;
left:0;
top:0;
width:0;
height:0;
}

. Pos_rel. Icon2 {
Display:block;
BORDER-WIDTH:9PX 9px 9px 0;
Border-color:transparent #fff Transparent transparent;
Border-style:solid;
Position:absolute;
left:4px;
Top: -9px;
width:0;
height:0;
}

Three ways to make triangles with CSS pseudo-class

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.