html - 带有实心边框的 CSS 插入边框半径

标签 html css css-shapes insets

我知道我可以使用径向渐变创建内嵌/倒置边框,如下所示:Inset border-radius with CSS3 ,但我想知道的是,我是否可以在生成的形状周围绘制一个 1px 的实线边框,如下图所示:
enter image description here

我不仅希望左下角的半径也被边框反转,而且剩余空间内的背景颜色必须是透明的。是否可以使用 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/

相关文章:

jquery - JQuery 能否在换行到第二行之前检测到一行中的最后一个元素?

html - 如何为与页面结构重叠的单个页面部分设置不同的背景颜色?

html - 使用 CSS 绘制三 Angular 形裁剪形状

javascript - 页面另存为html后隐藏按钮

javascript - 在 JS 中自行执行并调用函数

html - 无法保持特定于一个类/id 的超链接样式

html - CSS 中形状的粒度

html - 菜单右箭头在悬停时隐藏

javascript - "If"语句单击按钮后如何检查是否选中了多个复选框?

html - 如何使用 Mozilla 浏览器自动打印横向?