CSS的HTML背景图像 [英] CSS Background-image over HTML img
本文介绍了CSS的HTML背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有可能获得背景图像在某个div(像一个面具)的所有html img的顶部
I was wondering whether it's possible to get background-image to be on top of all html img's in a certain div (like a sort of mask)
我试过:
#content img{
position:relative;
background-image:url('./images/image-mask-2.png');
z-index:100;
}
推荐答案
尝试使用填充使用宽度和高度
try to use padding instead of using width and height
#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;
}
这篇关于CSS的HTML背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文