Alv*_*dez 4 html css css3 css-shapes
如何使这个形状只使用CSS

我尝试过的:
.button-up {
border-top: 100px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom: 35px solid transparent;
width: 200px;
}Run Code Online (Sandbox Code Playgroud)
<div class="button-up"></div>Run Code Online (Sandbox Code Playgroud)
我会linear/radial-gradient跟这样的:
.box {
width:200px;
height:200px;
border-radius:50%;
background:
linear-gradient(-30deg, white 50%,transparent 50.5%),
linear-gradient(30deg, white 50%,transparent 50.5%),
radial-gradient(farthest-side at center,transparent 40%,blue 41%);
}Run Code Online (Sandbox Code Playgroud)
<div class="box">
</div>Run Code Online (Sandbox Code Playgroud)
并带边框:
.box {
width:200px;
height:200px;
border-radius:50%;
background:
linear-gradient(to top,white 58.5%,transparent 60%),
linear-gradient(-30deg, white calc(50% - 4px),green calc(50% - 4px) 50%,transparent 0),
linear-gradient(30deg, white calc(50% - 4px),green calc(50% - 4px) 50%,transparent 0),
radial-gradient(farthest-side at center,
transparent calc(42% - 5px),
green calc(42% - 4px) 42%,
blue 42% calc(100% - 4px),green calc(100% - 3px));
}Run Code Online (Sandbox Code Playgroud)
<div class="box">
</div>Run Code Online (Sandbox Code Playgroud)
你也可以考虑更容易的SVG:
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' width='300' height='300' fill='blue'>
<path stroke="green" stroke-width=1 d='M24 32 C28 28 37 28 40 32 L52 22 C38 8 26 8 12 22 Z' />
</svg>Run Code Online (Sandbox Code Playgroud)
这是另一个想法clip-path:
.box {
width:200px;
height:200px;
border-radius:50%;
background:
radial-gradient(farthest-side at center,transparent 40%,blue 41%);
clip-path: polygon(0 0,0 10%, 50% 50%, 100% 10%,100% 0);
}Run Code Online (Sandbox Code Playgroud)
<div class="box">
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
371 次 |
| 最近记录: |