<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
.triangle_top,
.triangle_bottom,
.triangle_left,
.triangle_right {
width: 100px;
height: 100px;
background: #06ac68;
margin: 20px;
position: relative;
float: left;
border-radius: 10px;
}
.triangle_top:before {
content: '';
width: 0px;
height: 0px;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #cccccc;
position: absolute;
top: -10px;
left: 42px;
}
.triangle_bottom:before {
content: '';
width: 0px;
height: 0px;
border-top: 10px solid #cccccc;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
position: absolute;
top: 100px;
left: 42px;
}
.triangle_right:before {
content: '';
width: 0px;
height: 0px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid #cccccc;
position: absolute;
top: 42px;
right: -10px;
}
.triangle_left:before {
content: '';
width: 0px;
height: 0px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid #cccccc;
position: absolute;
top: 40px;
left: -10px;
}
</style>
</head>
<body>
<!--三角形在上-->
<div class="triangle_top"></div>
<!--三角形在下-->
<div class="triangle_bottom"></div>
<!--三角形在左-->
<div class="triangle_left"></div>
<!--三角形在右-->
<div class="triangle_right"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.triangle{
width:200px;
height:100px;
position: relative;
margin:50px auto;
border:1px solid red;
}
.triangle:before{
content:"";
border:10px solid transparent;
border-bottom-color:black;
position:absolute;
left:20px;
top:0;
margin-top:-20px;
}
.triangle:after{
content:"";
border:10px solid transparent;
border-bottom-color:white;
position: absolute;
top:0;
left:20px;
margin-top:-19px;
}
</style>
</head>
<body>
<div class="triangle"></div>
</body>
</html>