用CSS中的图像模糊div

Mat*_*iak 1 css background-image

有没有办法伪造前景图像与CSS中的背景图像相似?它不会存在于div中的其他元素后面,而是会掩盖元素中的所有内容.

Zet*_*eta 5

使用伪元素(::beforeIE≤7不起作用):

.obscured{     
    position: relative;
}
.obscured::before{
    position: absolute; /* maximize the pseudo-element */
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background-color:rgba(0,0,0,0.3); /* use background-image here */
    content: " "; /* it needs actual content, an empty space is enough */
}
Run Code Online (Sandbox Code Playgroud)

也可以看看: