【问题标题】:Border radius gap [duplicate]边界半径间隙[重复]
【发布时间】:2019-07-05 19:38:45
【问题描述】:

我在 div 中添加了边框和边框半径。在那个 div 里面有 ::before.wrapper 继承 border-radius 但不知何故边框显示错误。有明显的差距。

.wrapper {
  width: 500px;
  height: 200px;
  border: 10px solid black;
  border-radius: 40px;
  background-color: #ccc;
  overflow: hidden;
  position: relative;
}

.wrapper::before {
  border: 2px solid red;
  box-shadow: 0 0 2px rgba(1, 117, 255, 0.9);
  opacity: 1;
  border-radius: inherit;
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
<div class="wrapper"></div>

这可以通过 css 解决吗?

【问题讨论】:

标签: html css


【解决方案1】:

对于您当前的布局,border-radius: 30px; for ::before 有效:

.wrapper {
  width: 500px;
  height: 200px;
  border: 10px solid black;
  border-radius: 40px;
  background-color: #ccc;
  overflow: hidden;
  position: relative;
}

.wrapper::before {
  border: 2px solid red;
  box-shadow: 0 0 2px rgba(1, 117, 255, 0.9);
  border-radius: 30px;
  opacity: 1;
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
<div class="wrapper"></div>

【讨论】:

    猜你喜欢
    • 2014-04-30
    • 1970-01-01
    • 2012-02-24
    • 2012-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-14
    相关资源
    最近更新 更多