Create a triangle border with CSS.

Source: Internet
Author: User

Create a triangle border with CSS.
<! Doctype html>
<Html lang = "en-US">
<Head>
<Meta charset = "UTF-8">
<Title> Create a triangle border with characters </title>
<Style type = "text/css">
* {Margin: 0; padding: 0 ;}
Body {font-family: SimSun ;}
H1 {text-align: center ;}
. Demo1 {
Width: 100px;
Margin: 20px auto;
Border: 1px solid red;
Height: 100px;
}
. Demo1 em,. demo1 span
{
Display: block;
Width: 30px;
Height: 15px;
Font-size: 30px;
Overflow: hidden;
_ Position: relative;
Margin-left: 20px;
}
. Demo1 em {
Margin-top:-16px;
Color: red;
Font-style: normal;
}
. Demo1 span
{
Margin-top:-14px;
Color: white;
}




. Demo2 {
Width: 300px;
Border: 1px solid # F00;
Height: 100px;
Position: relative;
Margin-left: auto;
Margin-right: auto;
}
. Demo2 em,. demo2 span {
Font-style: normal; font-size: 30px; position: absolute; left:-16px; top: 40px; color: red ;}
. Demo2 span {
Left:-14px;
Color: white;
}
/*


Dialog bubbles


Usage: Use the. speech-bubble and. speech-bubble-DIRECTION classes.


<Div class = "speech-bubble-top"> Hi there </div>


*/
. Speech-bubble {
Position: relative;
Background-color: #292929;
Width: 200px;
Height: 150px;
Line-height: 150px;
Color: white;
Border-radius: 10px;
Font-family: sans-serif;


}*/
. Speech-bubble: after {


Content :'';


Position: absolute;
Width: 0;
Height: 0;
Border: 15px solid
}




. Speech-bubble-top: after {
Border-bottom-color: # 0000FF;
Left: 50%;
Bottom: 100%;
Margin-left:-15px;


}


. Speech-bubble-right: after {


Border-left-color: #292929;
Left: 100%;
Top: 50%;
Margin-top:-15px;
}
. Speech-bubble-bottom: after {


Border-top-color: #292929
Top: 100%;
Left: 50%;
Margin-left:-15px;
}
. Speech-bubble-left: after {


Border-right-color: #292929;


Top: 50%;


Right: 100%;


Margin-top:-15px;


}


</Style>
</Head>
<Body>
<H1> demo1 uses the margin Method <Div class = "demo1">
<Em> & #9670; </em>
<Span> & amp; #9670; </span>
</Div>
<H1> demo2 uses the position method <Div class = "demo2">
<Em> & #9670; </em>
<Span> & amp; #9670; </span>
</Div>






<Div class = "speech-bubble-top">
</Div>
<Div class = "speech-bubble-bottom">


Arrow at the bottom


</Div>


<Div class = "speech-bubble-left">

Arrow on the left

</Div>


<Br/>
<Div class = "speech-bubble-right">
Arrow on the right


</Div>


</Body>
</Html>

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.