html - 椭圆形切口形状元素

标签 html css

<分区>

我想实现这样的形状: enter image description here

.left{float:left; width:40%; background:#000; height:60px; border-top-right-radius:50%;}
.center{float:left; width:30%; background:#000; height:30px;}
.right{float:left; width:40%; background:#000; height:60px; border-top-left-radius:50%;}
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>

我需要图片上黑色部分的形状,剪下来的部分必须是透明的,这样你才能看到背景。中间部分不必是响应式的,可以用 100px 固定,有没有一些反转的边框半径的方法?如有任何帮助,我们将不胜感激。

最佳答案

你可以试试这段代码

.oval{ 
    background: #000;
    height: 60px;
    width: 300px;
    margin: 0px auto;
    margin-top: 100px;
    position: relative;
}
.left{ 
    width: 110px;
    background: #000;
    height: 70px;
    border-top-right-radius: 100px;
    position: absolute;
    left: 0;
    top: -33px;
}
.center{
    width: 114px;
    background: #ffffff;
    height: 100px;
    position: absolute;
    top: -75px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 53px;
    z-index: 99;
}
.right{
    width: 110px;
    background: #000;
    height: 70px;
    border-top-left-radius: 100px;
    position: absolute;
    right: 0;
    top: -33px;
}
<div class="oval">
  <div class="left"></div>
  <div class="center"></div>
  <div class="right"></div>
</div>

关于html - 椭圆形切口形状元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59352403/

上一篇:css3 使用两个动画 : secound animation not starting from first animation postion

下一篇:html - Bootstrap 样式未在 asp.net gridview 中呈现并显示其他一些类

相关文章:

html - 层的奇怪 css 行为

html - 将内容扩展到完整的父级宽度

javascript - 停止一个 div 的背景颜色覆盖另一个 div 的内容,旋转并因此重叠,div

html - 为什么带有 > 符号(直接子项)的 CSS 选择器会覆盖默认样式?

javascript - Django + skelJS/静态文件问题/CSS 中对图像的引用

javascript - 仅当 DIV > TABLE >TR 可见时才显示 DIV > SPAN

javascript - 如何使用 Javascript 输出 HTML '<div>' 元素

html - 3个div没有对齐

javascript - 使用链接更改 div

javascript - 如何使纵向视频保持在自己的区域,当它倾斜到水平时应该进入全屏