不知道如果这是可能的,怎么样,但是我试着用我的代码中的元素的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>
示例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;}解决方法 我会把一个绝对定位,z指数:100;具有背景的跨度(或跨度):url(“myImageWithRoundedCorners.jpg”);在#mainWrapperdivWithBGImage中设置它。 总结
以上是内存溢出为你收集整理的html – CSS显示div背景图像顶部其他包含的元素全部内容,希望文章能够帮你解决html – CSS显示div背景图像顶部其他包含的元素所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)