css - CSS半圆背景
问题描述
我想要实现的目标: 图片链接
我的代码目前的样子:
.half-circle {
background-color: white;
}
<div style="background-color: black;">
<div class="half-circle">
<img src="https://i.imgur.com/WBtkahj.png" />
</div>
</div>
<div>Some text here that should't be moved</div>
我尝试使用具有白色背景和 500 半径的填充,但它会将文本向下推。
解决方案
您可以查看radial-gradient()
并调整一下尺寸
.half-circle {
min-height: 12vw;
padding-bottom: 4%;
background: radial-gradient(circle at top, white 17vw, transparent 17.1vw)
}
.half-circle img {
display: block;
margin: auto;
max-width: 15vw
}
<div style="background-color: black;">
<div class="half-circle">
<img src="https://i.imgur.com/WBtkahj.png" />
</div>
</div>
<div>Some text here that should'nt be moved</div>
推荐阅读
- xamarin.forms - Xamarin Android 打开 PDF 文件
- vb.net - VB.NET 中的 Activeform
- python - 是否可以在python中有永久变量
- reactjs - 在 Firebase 中将 Array-contains 与 == 结合使用
- tableau-api - 设置 Tableau Server 的语言不起作用
- kubernetes - 如何将集群 dns 设置为使用 coredns
- google-api - 如何通过脚本合并多个 Google 幻灯片文件
- c++ - 在 c++ 中设置控制台窗口大小和缓冲区大小(win32 应用程序)
- windows - 调用 SetDisplayConfig 时,如何获取用于 ModeArray 和 PathArray 结构的目标 ID?
- android - 如何对返回 livedata 的函数进行单元测试