CSS背景图像HTML img

Man*_*led 7 html css

我想知道是否有可能让背景图像在某个div中的所有html img之上(就像一种掩码)

我试过了:

#content img{
    position:relative;
    background-image:url('./images/image-mask-2.png');
    z-index:100;
}
Run Code Online (Sandbox Code Playgroud)

小智 7

尝试使用填充而不是使用宽度和高度

#content img{
    height: 0;
    width: 0;
    padding: 35px 120px; // adjust that depend on your image size
    background-image: url('YOUR_IMAGE_PATH');
    background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)