在透明标题 div *下方*滚动主体?
我正在尝试实现具有固定标题和固定侧边栏的滚动主体。我想我已经快到了,只是正文在标题顶部滚动。我希望我可以简单地增加标题相对于正文的 z 索引,但这不起作用,因为标题大部分是透明的。
这是网站:链接
有什么想法吗? 谢谢
编辑:我应该澄清一下,我希望内容在标题下方滚动时不可见,而不仅仅是作为其下方的一层。
I am trying to achieve a scrolling body with fixed header and fixed sidebar. I think I am almost there except that the body scrolls on top of the header. I wish I could simply increase the z-index of the header in relation to the body but this doesn't work since the header is mostly transparent.
Here is the site: link
Any ideas?
Thanks
Edit: I should clarify that I want the content to be invisible as it scrolls underneath the header, not simply as a layer beneath it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对正文和标题使用相同的背景图像,但使用
background-position:fixed
。这样,标题将具有不透明度,以便内容在下方滚动并隐藏。使用固定位置将确保两个图像看起来无缝。
顺便说一句,我无法查看您网站上的整个侧边栏,您可能需要重新考虑使用这种严格的布局。
Use the same background image for your body and header, but with
background-position:fixed
.This way, the header will have opacity for the content to scroll beneath and be hidden. Using fixed position will ensure that the two images appear seamless.
On a side note, I am unable to view the entire sidebar on your site, you may want to reconsider using such a rigid layout.
这是您的代码:
z 索引的工作方式是,要包含在分层中的任何内容也需要有一个 z 索引集。因此,现在在您的代码中,仅设置了
#thebody
。将其添加到#theheader
:这会将
#theheader
置于#thebody
之上。祝你好运,如果您有疑问,请告诉我。Here is your code:
The way z-indexs work is, anything to be included in the layering needs to also have an z-index set. So, in your code right now, only
#thebody
is set. Add this to#theheader
:This places
#theheader
over the#thebody
. Good luck, and let me know if you have questions.