css 元素使用背景色加透明度,伪元素背景色不生效问题

1、元素使用了背景色且透明度,伪元素覆盖不了
.all-alarm {
	color: #fff;
    background: #1890FC;
    opacity: 0.6;
    &::before {
     content: "";
      left: 0px;
      top: 0px;
      position: absolute;
      width: 3px;
      height: 0.38rem;
      background: #1890FC;
      opacity: 1;
    }
}

在这里插入图片描述

在这里插入图片描述

2、修改成使用rgba
.all-alarm {
  color: #fff;
  background: rgba(24, 144, 252, .6);
  &::before {
    content: "";
    left: 0px;
    top: 0px;
    position: absolute;
    width: 3px;
    height: 0.38rem;
    background: #1890FC;
  }
}

在这里插入图片描述

小猪佩奇,我配你!


版权声明:本文为agua001原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。