将带有背景的 div 放置在另一个 div 的下方
我在 html5 中有以下结构:
html
- body
- header
- #wrapper
- aside nav
- footer
标题有 2 个带背景图像的大 div,一个是徽标,另一个是子徽标。
导航栏也有背景图像,我刚刚向我的包装器添加了背景,它需要有背景图像,因为图像需要随着包装器内的内容而扩展。包装纸也位于 margin-top : -105px 处,以便包装纸背景的一部分位于徽标和子徽标下方,因为这两者都不是 100% 宽,包装纸背景显示在侧面,就像纸页一样。
我的问题是包装此时位于徽标和子徽标之上。我尝试将 z 索引 10 添加到标头,将 z 索引 -1 添加到包装器,但没有成功。
我可以尝试什么使包装背景图像位于标题后面?
谢谢。
I have the following structure in html5:
html
- body
- header
- #wrapper
- aside nav
- footer
The header has 2 big divs with background images, one being logo and another being a sub logo.
The nav bar also has background image, and I just added a background to my wrapper, it needs to have a background image because the image needs to expand with the contents inside the wrapper. The wrapper also is positioned at margin-top : -105px so that a portion of the wrappers background goes under the logo and sublogo, since both of those are not 100% wide, the wrappers background shows on the sides, much like a paper page.
My problem is that the wrapper is at this moment, on top of logo and sublogo. I have tried adding a z-index of 10 to my header and z-index of -1 to the wrapper, but no luck.
What can I try to make the wrappers background image go behind the header?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
z-index
仅适用于positions:relative
、absolute
或fixed
的元素。将
position:relative;
和z-index
添加到徽标和子徽标。z-index
only works on elements that arepositions:relative
,absolute
, orfixed
.Add
position:relative;
and az-index
to the logo and sub-logo .