CSS border属性 和radius属性做出的等边梯形 圆形 椭圆 三角形 扇形

111 阅读1分钟

都是基于边框属性做出的图型

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
   <style>
       .max>div{
           display: inline-block;
           margin-right: 100px;
           vertical-align: bottom;
       }
       /* 等边梯形 */
       .box{
           width: 20px;
           height: 20px;
           border-top:100px solid transparent ;
           border-left:100px solid transparent ;
           border-right:100px solid transparent ;
           border-bottom:100px solid black ;
           /* 上左右都为 transparent(透明色) */
       }
       /* 三角形 */
       .trigon{
           width: 0px;
           height: 0px;
           border-top:100px solid transparent ;
           border-left:100px solid transparent ;
           border-right:100px solid transparent ;
           border-bottom:100px solid black ;
       }
       /* 圆形 */
       .round{
           width: 100px;
           height: 100px;
           background-color: black;
           border-radius: 50%;
       }
       /* 椭圆 */
       .oval {
           width: 200px;
           height: 100px;
           background-color: black;
           border-radius: 50%;
       }
       /* 扇形 */
       .sector {
           width:0px;
           height:0px;
           border-top:100px solid transparent ;
           border-left:100px solid transparent ;
           border-right:100px solid transparent ;
           border-bottom:100px solid black ;
           border-radius: 50%;
       }

   </style>
</head>
<body>

   <div class="max">
       <div class="box"></div>
       <div class="trigon"></div>
       <div class="round"></div>
       <div class="oval"></div>
       <div class="sector"></div>
   </div>
</body>
</html>