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>
        #circle{
            width:0;
            height: 0;
            border: 50px solid green ;
            border-right: 50px solid greenyellow ;
            border-left: 50px solid greenyellow;/*此时是正方形*/
            border-radius: 50%;/*此时是圆*/
            transform: rotate(-45deg);/*逆时针旋转45deg*/
        }
    </style>
</head>
<body>
<div id="circle">
</div>
</body>
</html>

另外一种方法:

<!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>
        #circle {
            width: 100px;
            height: 100px;
            background-color: #86CE2F;
            border-radius: 100px 100px 100px 100px;/*此时是圆*/
            /*border-radius: 100px 0px 0px 100px;/*此处可以思考一下*/
            /*border-radius: 100px 0px 0px 0px;/*此时是1/4圆*/
        }
    </style>
</head>
<body>
<div id="circle">
</div>
</body>
</html>
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页