相关疑难解决方法(0)

CSS在其他包含的元素之上显示div背景图像

不确定这是否可能以及如何,但我尝试在我的代码中使用元素的z-index但没有成功.

我有一个div元素,其背景图像设置在css中.在div中,我有其他元素,比如div和img.我想让包含背景图像的主要div保持在最顶层,因为我希望背景图像显示在其他元素之上(此背景图像有一些圆角,我想在图像顶部显示在这个div).

示例HTML:

<div id="mainWrapperDivWithBGImage">
   <div id="anotherDiv">
      <!-- show this img behind the background image 
      of the #mainWrapperDivWithBGImage div -->
      <img src="myLargeImage.jpg" />
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS示例:

/* How can I make the bg image of this div show on top of other elements contained
   Is this even possible? */

#mainWrapperDivWithBGImage {
  background: url("myImageWithRoundedCorners.jpg") no-repeat scroll 0 0 transparent;
  height: 248px;
  margin: 0;
  overflow: hidden;
  padding: 3px 0 0 3px;
  width: 996px;
}
Run Code Online (Sandbox Code Playgroud)

html css z-index background-image

17
推荐指数
1
解决办法
10万
查看次数

CSS背景图像HTML img

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

我试过了:

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

html css

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

css ×2

html ×2

background-image ×1

z-index ×1