我知道我可以使用径向渐变创建内嵌/倒置边框,如下所示:Inset border-radius with CSS3 ,但我想知道的是,我是否可以在生成的形状周围绘制一个 1px 的实线边框,如下图所示:
我不仅希望左下角的半径也被边框反转,而且剩余空间内的背景颜色必须是透明的。是否可以使用 CSS3 和 HTML(我现在对 canvas 或 SVG 不感兴趣)?
最佳答案
演示: Jsfiddle here
代码
figure {
position: relative;
width: 200px;
height: 120px;
margin: 100px auto;
overflow: hidden;
border: 1px solid black;
border-right: none;
border-bottom: none;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
}
figure:before,
figure:after {
content: '';
position: absolute;
}
figure:before {
right: -50%;
top: 0;
background: transparent;
width: 172px;
height: 200px;
border: 1px solid black;
border-radius: 100%;
box-shadow: 0 0 0 100em red;
}
figure:after {
left: -1px;
bottom: 0px;
height: 16px;
width: 128px;
border-top-left-radius: 0;
border-bottom-left-radius: 5px;
border-left: 1px solid black;
border-bottom: 1px solid black;
}
<figure></figure>
关于html - 带有实心边框的 CSS 插入边框半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18595832/