插图框阴影显示周围的边框,需要将其隐藏

时间:2018-07-23 21:23:14

标签: html css css3 box-shadow

我用css创建了一个div使其变成圆圈,并添加了内部框阴影

.circle {
  width: 690px;
  height: 690px;
  background: #000;
  border-radius: 50%;
  box-shadow: inset 0 0 80px 50px rgba(255, 255, 255, 1);
  position: absolute;
  left: -100px;
  top: -100px;
}
<div class="circle"></div>

enter image description here

1 个答案:

答案 0 :(得分:1)

添加一个小的填充并调整background-clip

.circle {
  width: 690px;
  height: 690px;
  background: #000;
  border-radius: 50%;
  box-shadow: inset 0 0 80px 50px rgba(255, 255, 255, 1);
  padding: 1px;
  background-clip: content-box;
  position: absolute;
  left: -100px;
  top: -100px;
}
<div class="circle"></div>

您也可以使用radial-gradient重新创建它们:

.circle {
  width: 690px;
  height: 690px;
  background: radial-gradient(#000 57%,transparent 70%);
  border-radius: 50%;
  position: absolute;
  left: -100px;
  top: -100px;
}
<div class="circle"></div>