Implement hollow triangle and hollow triangle

Source: Internet
Author: User

Implement hollow triangle and hollow triangle

Background: A project has a tab switch that requires the effect of a hollow triangle. As a back-end engineer, I really don't know how to write it. I found some implementation methods on the Internet and found that most of them are solid triangles. Later, I finally found a hollow triangle, which suddenly burst into tears. The implementation results are relatively rough, but the idea is still clear. I have made some improvements on the basis of the original, and added some results.

Hollow triangle principle: Mainly implemented using element pseudo classes (: before,: after)

: Ps: color change

Implementation Code:

<Style>
# Talkbubble {
Width: 120px;
Height: 80px;
Position: relative;
-Moz-border-radius: 10px;
-Webkit-border-radius: 10px;
Border-radius: 10px;
Border: 1px #808080 solid;
Background-color: # fff;
}

# Talkbubble: before {
Content :"";
Position: absolute;
Top: 100%;
Left: 50px;
Width: 0;
Height: 0;
Border-left: 15px solid transparent;
Border-top: 15px solid #808080;
Border-right: 15px solid transparent;
}

. Inlayer: after {
Content :"";
Position: absolute;
Top: 100%;
Left: 51px;
Width: 0;
Height: 0;
Border-left: 14px solid transparent;
Border-top: 14px solid # fff;
Border-right: 14px solid transparent;
}

# Talkbubble: hover {
Background-color: # ff0000;
}

. Inlayer: hover: after {
Width: 0;
Height: 0;
Border-left: 14px solid transparent;
Border-top: 14px solid # ff0000;
Border-right: 14px solid transparent;
}
</Style>

<! -- Html -->
<Div id = "talkbubble" class = "inlayer">
Hollow triangle
</Div>

 

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.