css鼠标悬浮添加蒙层

.item元素在被悬停(hover)时其::after伪元素的样式。

.contenterBottomCenter > .box > .item:hover::after {  
    position: absolute; /* 设置伪元素的定位方式为绝对定位 */  
    top: 0; /* 设置伪元素的顶部与其父元素(.item)的顶部对齐 */  
    left: 0; /* 设置伪元素的左侧与其父元素(.item)的左侧对齐 */  
    content: ''; /* 设置伪元素的内容为空,但通常content属性是必须的,即使为空,也是为了让伪元素显示出来 */  
    width: 100%; /* 设置伪元素的宽度为其父元素(.item)宽度的100% */  
    height: 100%; /* 设置伪元素的高度为其父元素(.item)高度的100% */  
    background-color: rgba(20, 16, 16, 0.4); /* 设置伪元素的背景颜色为半透明黑色,RGBA颜色值表示红色20、绿色16、蓝色16,透明度为0.4 */  
}

猜你喜欢

转载自blog.csdn.net/H2608520347/article/details/140933774