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>