<div class="triangle-left">
<div></div>
</div>?
.triangle-left {
border-color: transparent black transparent transparent;
border-style: solid;
border-width: 20px;
width: 0;
height: 0;
}
.triangle-left div
{
border-color: transparent white transparent transparent;
border-style: solid;
border-width: 10px;
width: 0;
height: 0;
position:relative;
top:-9px;
left:0px;
}?
Run Code Online (Sandbox Code Playgroud)
这是一个三角形,内部有一个白色三角形,呈现出箭头的外观.有关CSS3三角形的更多信息,请参见此处:
http://jonrohan.me/guide/css/creating-triangles-in-css/
HTML
<div class="angle"></div>
Run Code Online (Sandbox Code Playgroud)
CSS
.angle:after { /* Thanks to :after just one div is necessary */
content: '.';
border-top: 20px solid #000; /* NW triangle gap */
border-bottom: 20px solid #000; /* SW triangle gap */
border-left: none;
border-right: 20px solid transparent; /* W triangle */
position: relative;
left: 20px;
}
.angle {
font-size: 0px; line-height: 0%; width: 0px; /* Necessary to not screw up the layout */
border-top: 20px solid transparent; /* NE triangle gap */
border-bottom: 20px solid transparent; /* SE triangle gap */
border-left: none;
border-right: 20px solid #000; /* E triangle */
}
Run Code Online (Sandbox Code Playgroud)
更新:较小的版本
这些是2个重叠的三角形.一个是黑色,一个是白色.
相同的HTML,不同的CSS
.angle:after {
content: '.';
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: none;
border-right: 10px solid white;
position: relative;
left: 5px;
}
.angle {
font-size: 0px; line-height: 0%; width: 0px; /* Necessary to not screw up the layout */
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: none;
border-right: 10px solid #000;
}
Run Code Online (Sandbox Code Playgroud)