An application example of CSS border triangle

Source: Internet
Author: User

I learned about a technology named "css border triangle" in the morning. It is implemented in pure css2 and compatible with various browsers (including Ie6). It worked very well. At that time, it was "inner niu ", sense of strength. I did not dare to learn the same things. I quickly started an application demo, and I could introduce this technology to more friends. The effect is as follows:

Common contacts common contacts

Note:

1. outer border: "rounded corner" is found ".

2: triangle: Wow! Not an image. Click again. Wow, too.

Pure css2 implementation, obvious effect, simple technology, is really suitable for all ages. The demo code is as follows:

Copy to ClipboardReference: [www.bkjia.com] <style type = "text/css">
Body {
Padding: 20px;
}
*{
Padding: 0;
Margin: 0;
}
. Br-test {
Width: 300px;
}
. Items {
Border-color: # ccc;
Border-style: solid;
Border-width: 0 2px;
Padding: 5px;
}
. Items-item {
Position: relative;
Border: # CCC 1px solid;
Height: 18px;
Margin: 5px 0 0 0;
}
. Items-item h3 {
Position: absolute;
Left: 24px;
Font-size: 14px;
}
. Items-item-triangle {
Position: absolute;
Left: 5px;
Width: 0;
Height: 0;
Overflow: hidden;
Font-size: 0;
Line-height: 0;
Border-color: transparent # CCC;
Border-style: dashed solid;
Border-width: 8px;
Cursor: pointer;
}
. Click {
Left: 0;
Top: 5px;
Border-color: # CCC transparent;
Border-style: solid dashed;
}
. Top-border {
Border-bottom: 3px solid # ccc;
Border-left: 3px dotted transparent;
Border-right: 3px dotted transparent;
}
. Bottom-border {
Border-top: 3px solid # ccc;
Border-left: 3px dotted transparent;
Border-right: 3px dotted transparent;
}
</Style>
<Script type = "text/javascript" src = "http://www.bkjia.com/uploads/common/js/jquery-1.4.2.min.js"> </script>
</Head>

<Body>
<Div class = "br-test">
<Div class = "top-border"> </div>
<Div id = "br-items" class = "items">
<Div class = "items-item">
<Div class = "items-item-triangle"> </div>
<H3> common contacts </Div>
<Div class = "items-item">
<Div class = "items-item-triangle"> </div>
<H3> common contacts </Div>
<Div class = "items-item">
<Div class = "items-item-triangle"> </div>
<H3> common contacts </Div>
</Div>
<Div class = "bottom-border"> </div>
</Div>
<Script type = "text/javascript">
$ (". Items-item-triangle", $ ("# br-items"). each (function (){
Var that = $ (this );
That. click (function (){
$ (This). toggleClass ("click ");
});
});
</Script>

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.