css实现三角形和梯形

  • border实现三角形(当宽高为0)
<!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>
        .a{
        //当宽度和高不存在时
            border-top: 100px solid #000;
         	height:0;
         	width:0;
            border-left:100px solid green;
            border-right: 100px solid pink;
            border-bottom: 100px solid blue;
        }
    </style>
</head>
<body>
    <div class="a"></div>
</body>
</html>

css实现三角形和梯形

  • border实现梯形(当宽高存在时)
<!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>
        .a{
        //当宽度和高存在时
            border-top: 100px solid #000;
         	height:100px;
         	width:100px;
            border-left:100px solid green;
            border-right: 100px solid pink;
            border-bottom: 100px solid blue;
        }
    </style>
</head>
<body>
    <div class="a"></div>
</body>
</html>

css实现三角形和梯形