css 实现三角形的原理

时间:2023-03-09 08:34:48
css 实现三角形的原理
 <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title> <style>
body{
padding:20px;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #0066cc;
} .f {
width: 0;
height: 0;
border-right: 40px solid #ff0000;
border-left: 40px solid #ff0000;
border-bottom: 40px solid #000;
border-top: 40px solid #000;
} .t1{
height:50px;
width:50px;
background:#fff; }
.t2 {
height: 50px;
width: 50px;
background: #fff;
border-top: 10px solid #f00;
border-right: 10px solid #0f0;
}
.t3 {
height: 50px;
width: 50px;
background: #fff;
border-top: 10px solid #f00;
border-right: 10px solid #0f0;
border-bottom: 10px solid #f00;
border-left: 10px solid #0f0;
}
.t4 {
height: 0px;
width: 0px;
background: #fff;
border-top: 10px solid #f00;
border-right: 10px solid #0f0;
border-bottom: 10px solid #f00;
border-left: 10px solid #0f0;
}
.t5 {
height: 0px;
width: 0px;
border-top: 10px solid #f00;
border-right: 10px solid transparent;
border-bottom: 10px solid #f00;
border-left: 10px solid transparent;
}
.t6 {
height: 0px;
width: 0px;
border-right: 10px solid transparent;
border-bottom: 10px solid #f00;
border-left: 10px solid transparent;
}
</style> </head>
<body style="background:#ccc"> <div class="t1"></div><br /><br />
<div class="t2"></div><br /><br />
<div class="t3"></div><br /><br />
<div class="t4"></div><br /><br />
<div class="t5"></div><br /><br />
<div class="t6"></div><br /><br /> </body>
</html>

测试效果图:

css 实现三角形的原理