html - 如何切割溢出的div css

标签 html css overflow

我需要知道如何从蓝色框中切下灰色部分。

enter image description here

下图中的红色箭头显示了我想从蓝色框中剪切的部分。这是我的代码:

.father {
  height: 400px;
  width: 400px;
  margin: 150px auto;
  position: relative;
}

.border {
  position: relative;
  bottom: 50px;
  margin: auto;
  border-radius: 50%;
  width: 96%;
  height: 30%;
  background-color: #DDD;
}
	
<div class="father">
  <div class="border"></div>
</div>

最佳答案

据我了解,您希望将蓝色区域之外的灰色部分剪掉。如果是这样,请按以下步骤操作。

.father {
  height: 400px;
  width: 400px;
  margin: 150px auto;
  position: relative;
  background: lightblue;
  overflow: hidden;
}

.border {
  position: relative;
  bottom: 50px;
  margin: auto;
  border-radius: 50%;
  width: 96%;
  height: 30%;
  background-color: #DDD;
  z-index: 1;
}
<div class="father">
  <div class="border"></div>
</div>

关于html - 如何切割溢出的div css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38824293/

相关文章:

html - 背景图像顶部隐藏在浏览器书签栏下

html - 微软边缘 : overflow: hidden not working on box-shadow

css - DIV 溢出滚动停止短

html - Bootstrap 内部 flex 最小固定宽度

html - 如何取消转义 CSS

javascript - 使用变换而不是宽度/高度为 GPU 加速动画 div 的尺寸

html - 如何使用 bootstrap 4 居中表单

c - 如何读取大文件(最多 2 000 000 000 个字符)并存储它们

java - 从 Html 字符串建模一个类,实例化该类并从该字符串填充变量,然后从该类返回 html 字符串

javascript - 通过组合变量对多个输入字段进行表单验证