答案 0 :(得分:8)
linear-gradient
会这样做,并使用border-radius
将其设为一个圆圈。
div {
width: 50vw;
height: 50vw;
background: linear-gradient( -45deg, blue, blue 49%, white 49%, white 51%, red 51% );
border-radius: 50%;
}
<div></div>
答案 1 :(得分:1)
您可以这样做:
div {
border-radius: 50px;
border-right-color: red;
border-top-color: blue;
border-bottom-color: red;
border-left-color: blue;
border-width: 50px;
border-style: solid;
height: 0px;
width: 0px;
}
&#13;
<div>
</div>
&#13;
答案 2 :(得分:1)
您可以为圈子的每一半使用:before
和:after
个伪元素,并在父元素上添加transform: rotate()
。
.circle {
display: inline-block;
position: relative;
width: 200px;
height: 200px;
border-radius: 50%;
overflow: hidden;
transform: rotate(25deg);
}
.circle:after, .circle:before {
content: '';
position: absolute;
height: 100%;
width: 50%;
}
.circle:after {
background: #02FBFD;
left: -2px;
}
.circle:before {
background: #FE0103;
right: -2px;
}
&#13;
<div class="circle"></div>
&#13;