CSS实现遮罩效果

所用方式:

      background:rgba(色一,色二,色三,透明度);
    透明度最高值设置为1,意思是 100%不透明。
Html代码如下:
<div class="test">
            
</div>

 CSS代码如下:

.test{
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
}