css三角形顶部,圆形底部有不同的颜色

Zas*_*ast 2 css

如何为三角形添加不同颜色的圆底?

 #box {
    content:"";
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 150px 150px 150px;
    border-color: transparent yellow red blue;
    position: relative;
 }
Run Code Online (Sandbox Code Playgroud)

生产:

css输出

我需要的是底部的绿色部分,圆角:

期望的输出

小智 6

我想这会对你有所帮助

#box {
    content:"";
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 150px 150px 150px;
    border-color: transparent yellow red blue;
    position: relative;
 }
 #box:before{
    content: '';
    width: 300px;
    height:  300px;
    display: block;
    background-color:green;
    border-radius: 50%;
    position: absolute;
    left: -150px;
    z-index: -1;
 }
Run Code Online (Sandbox Code Playgroud)

片段:

#box {
    content:"";
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 150px 150px 150px;
    border-color: transparent yellow red blue;
    position: relative;
 }
 #box:before{
   content: '';
   width: 300px;
   height:  300px;
   display: block;
   background-color:green;
   border-radius: 50%;
   position: absolute;
   left: -150px;
   z-index: -1;
 }
Run Code Online (Sandbox Code Playgroud)
<div id="box"></div>
Run Code Online (Sandbox Code Playgroud)

检查小提琴

  • Whenever you can add SO snippet, please use that instead of jsFiddle, by the way you got my upvote. (2认同)