倒三角形在收起-展开交互中用的比较多,CSS画三角形代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.border {
height: 20px;
width: 20px;
border-color: #FF9600 #3366ff #12ad2a #f0eb7a;
border-style: solid;
border-width: 20px;
}
.triangle {
width: 0;
height: 0;
border: 20px solid #000;
border-top-color: red;
border-bottom-color: transparent;
border-left-color: transparent;
border-right-color: transparent;
/**
* 1、简化代码
widows: 0px;
height:0px;
border-top:20px solid red;
border-left:20px solid transparent;
border-right:20px solid transparent;
*/
/**
* 2、简化代码
widows: 0;
height:0;
border-color:#FF9600 transparent transparent transparent;
border-width:20px;
border-style:solid;
*/
}
.triangle02 {}
</style>
</head>
<body>
<ul>
<li> border的概念
<div class="border"></div>
</li>
<li> 三角形画法
<div class="triangle"></div>
</li>
</ul>
</body>
</html>