使用部分透明的 rgba() 值时,如何消除框阴影和 div 背景之间的间隙

How do I eliminate a gap between a box-shadow and a div background when using partially transparent rgba() values


出于某种原因,当在具有非固定(基于百分比)边界半径,它在div 元素的边缘 在背景和框阴影之间


我的问题是...

如何消除此间隙,同时保持具有背景颜色和框阴影透明度的非固定边框半径?


代码如下:

html {
  background-color: #cef;
  font-family: arial;
}
#background-underlay{
  background-color: white;
  text-align: center;
  margin-top: 5%; 
  padding-top:0px;
  color: black;
}
#overlay-div{
  display: flex;
  position: fixed;
  top: 15%;
  left: 15%;
  height: 70%;
  width: 70%;
  background-color: rgba(0, 0, 40, 0.8);
  color: white;
  border-radius: 50%;
  box-shadow: 0px 0px 2em 2em rgba(0, 0, 40, 0.8);
}
<h1 id="background-underlay">Background Text</h1>
<div id="overlay-div"></div>


示例元素的描述:

我尝试过但没有成功的事情:


(至少部分地)消除了差距的东西,不是解决方案:

模糊滤镜可以毫无问题地为您提供相同或至少相似的输出:

html {
  background-color: #cef;
  font-family: arial;
}
#background-underlay{
  background-color: white;
  text-align: center;
  margin-top: 5%; 
  padding-top:0px;
  color: black;
}
#overlay-div{
  display: flex;
  position: fixed;
  top: 8%;
  left: 8%;
  height: 81%;
  width: 81%;
  background-color: rgba(0, 0, 40, 0.8);
  filter:blur(1.5em);
  color: white;
  border-radius: 50%;
}
<h1 id="background-underlay">Background Text</h1>
<div id="overlay-div"></div>