【发布时间】:2017-06-13 16:44:02
【问题描述】:
我设法创建了带边框的简单图表。我想将简单的 border-color 更改为渐变。我试图使用 border-image 或 background 属性,但似乎不可能弯曲它以适应容器的拱形。 有没有办法在 css3 中实现这种效果?
HTML
<div class="pie">
<span class="overlay"></span>
</div>
CSS
.pie {
margin: 0 auto;
position: relative;
width: 116px;
height: 58px;
overflow: hidden;
}
.pie *,
.pie::before {
box-sizing: border-box;
}
.pie::before {
content: '';
width: inherit;
height: inherit;
border: 20px solid grey;
border-bottom: none;
border-top-left-radius: 175px;
border-top-right-radius: 175px;
position: absolute;
left:0;
}
.pie .overlay{
position: absolute;
top: 100%;
left: 0;
width: inherit;
height: inherit;
border: 20px solid;
border-top: none;
border-bottom-left-radius: 175px;
border-bottom-right-radius: 175px;
transform-origin: 50% 0;
border-color:yellow;/* background: linear-gradient(to right, rgba(228,232,7,1) 0%, rgba(0,218,156,1) 100%); */
transform: rotate(90deg);
}
【问题讨论】:
-
内圈需要透明吗?
-
不,只是纯色上的渐变。
标签: html css gradient pie-chart border-color