CSS—镂空遮罩层

CSS—镂空遮罩层

Scroll Down

正常的遮罩

一般使用的遮罩层的效果为全屏覆盖。制作也相对简单。

.mask {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  background-color: rgba($color: #000000, $alpha: 0.46);
}

镂空遮罩层

但是有时候很也会有类似引导的需求。这样的遮罩层就比较特殊,呈现的为镂空状态。如图:
1601369815656.jpg

如图的遮罩效果可以通过阴影的方式去做。

.hollowOutMask {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.46);
}

如果还有其他好的解决方案,欢迎评论区讨论!