CSS半圆背景

标签 css

我想要达到的目标: image link

我的代码目前的样子:

.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>

关于CSS半圆背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55189031/

相关文章:

html - 具有两个面板的 CSS 100% 宽度布局 - 为什么它不起作用?

用于在 Wordpress 中导航的 CSS 分隔符

javascript - 随机加载不在同一目录中的图像

javascript - jQuery Mobile 水平选择框

css - 是否有 css min-top 属性

javascript - 如何在响应式图片上实现 turn.js

c# - 在 C# 中将 HTML 元素导出到 Excel

html - 将 hr 在带有文本的 div 后面垂直对齐

html - 如何更改 ng-required 中星号符号的颜色

当嵌套在 DIV 中时,单击事件的 CSS CheckBox Hack 不起作用