html - CSS 边框向内 flex

标签 html css responsive-design

我想在元素内部构建带有 flex 边框的容器。可以只使用 css 吗?如果是容器可以有 auto 高度 image

最佳答案

你可以试试这个方法——在你的div前后画一个圆边的div

CSS:

#bend-inside{
    width: 500px;
    overflow: hidden;
}

#box-before{
    background-color: white;
    border-radius: 600px;
    height: 600px;
    width: 600px;
    display: inline-block;
    position: absolute;
    z-index: 2;
   right: 550px;
    top: -200px;
    overflow: hidden;
}

#box{
    background-color: #e5e5e5;
    width: 400px;
    height: 200px;
    margin: 0 auto;
    display: inline-block;
    overflow: hidden;
    position: absolute;
    z-index: 1;
    right: 200px;
}

#box-after{
    background-color: white;
    border-radius: 600px;
    height: 600px;
    width: 600px;
    display: inline-block;
    position: absolute;
    z-index: 2;
    right: -350px;
    top: -200px;
    overflow: hidden;
}

HTML:

<div id="bend-inside">
    <div id="box-before"></div>
    <div id="box"></div>
    <div id="box-after"></div>
</div>

Example

关于html - CSS 边框向内 flex ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23904255/

相关文章:

html - td 在 tr 中的定位

css - 如何为 p :treeTable 设置高亮颜色

html - 响应式,两列布局 : Move one column in between other column

html - 使用 ReactJS 的 IE 条件定位

html - 子子菜单宽度不会自动调整?

html - 如何让我的 flexbox 布局占用 100% 的垂直空间?

html - 适用于所有不同设备的响应式网页设计

javascript - 使用 contenteditable

html - 创建可粘贴到 Word 中的无边框表格

javascript - 响应式字体大小