HTML,CSS,显示div内部的背景

时间:2015-10-21 20:51:24

标签: html css background

我有身体和背景。我也有形象。我想隐藏图像并仅在隐藏图像的区域显示背景。只是为了使背景形状像图像一样。

任何人都知道我该怎么做?我应该使用哪些功能,工具?

我尝试了background-clip:content-box但它不起作用。

感谢您的任何建议!

#field {
    background: url(../images/10.png) no-repeat center;
    background-size: cover; 
    background-clip:content-box;
}
#img { 
position: relative;
top:0px;
z-index: -100;
}

more or less that is the point of my thinking in this image

1 个答案:

答案 0 :(得分:0)

所以你问的是如何只将背景放在图像

的位置

只需在图像中添加背景图像(这是... tada!透明像素!)

$(document).ready(function() {
    $('p').each(function(){
      $(this).html($(this).html().replace(/ /gi," "));
    });
});

CSS:

<img id="img" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">