【发布时间】:2021-04-23 18:22:53
【问题描述】:
我正在尝试做这样的事情:
它不是一个完整的或半圆,边缘有一点半径。还需要包含一些点来以百分比显示当前位置。有人可以告诉我如何将接近以下 3 个想法的东西放在一起吗?
.circle {
display: flex;
width: 200px;
height: 100px;
border-top-left-radius: 200px;
border-top-right-radius: 200px;
border: 10px solid gray;
border-bottom: 0;
}
.circle>.text {
font-size: 50px;
margin: auto;
}
.circle.gradient {
margin-top: 30px;
border-image-slice: 1;
border-width: 10px;
border-bottom: 0;
border-image-source: linear-gradient(to left, #6ECE34, #E6A749, #E5A749, #F71C1C);
}
.line {
position: relative;
margin-top: 30px;
width: 220px;
height: 10px;
border-radius: 5px;
background: linear-gradient(to left, #6ECE34, #E6A749, #E5A749, #F71C1C);
}
.line>.point {
position: absolute;
top: -3px;
left: 21%;
width: 8px;
height: 16px;
border-radius: 5px;
border: 1px solid black;
background: #FFF;
}
<!-- Just semi circle -->
<div class="circle">
<div class="text">
21
</div>
</div>
<!-- With gradient border -->
<div class="circle gradient"></div>
<!-- Maybe strech in Y -->
<div class="line">
<!-- Relative point -->
<div class="point"></div>
</div>
【问题讨论】:
-
创建一个 SVG。比破解 CSS 尝试容易得多。
-
这能回答你的问题吗? Half circle with CSS (border, outline only)
-
我会搜索一些关于它的东西@SeanStopnik
-
这很好@j08691,但我真的不想在其中使用 JS,我想要更轻巧更干净的东西。不过,我会尝试从中提取一些东西。