css如何实现四分圆并填充不同颜色

15 阅读1分钟

话不多少,直接上代码。

效果如图: 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
  </head>
  <body>
    <div>
      <style>
        .box{
          width: 200px;
          height: 200px;
          color: white;
          overflow: hidden;
          position: relative;
          border: 1px solid black;
          border-radius: 50%;
          background-color: gray;
        }
        .box > div{
          width: 100%;
          height: 100%;
          position: absolute;
          left: 50%;
          right: 50%;
          transform-origin: 0% 0%;
        }
        #left {
          transform: rotate(120deg);
          background: orange;
        }
        #right {
          transform: rotate(-30deg);
          background: blue;
        }
        #bottom {
          background: red;
          top: 75%;
          left: 6%;
        }
      </style>
      <div class="box">
        <div id="left">
        </div>
        <div  id="right">
        </div>
        <div  id="bottom">
        </div>
      </div>
    </div>
  </body>
</html>