简体   繁体   English

如何将固定位置的元素放在相对定位的元素之上?

[英]How do I put a fixed-position element on top of a relative positioned element?

Is it even possible? 可能吗? I made a header for my site position at "fixed". 我在“固定”位置为网站位置制作了标题。 The i also have an image positioned at "relative". 我也有一个图像定位在“相对”。 Whenever I scroll the site.... I noticed that the image was layered "above" the header. 每当我滚动站点时...。我注意到图像位于标题的“上方”。 Even the twitter profile widget i placed was above the header. 甚至我放置的twitter个人资料小部件都位于标题上方。 They both overlap the header and i dont want that. 他们都重叠标题,我不想要。 Any idea on how to resolve my problem? 关于如何解决我的问题有什么想法吗? please HELP! 请帮忙!

Btw.... ive heard that "fixed" is buggy esp in Android, where I am making my site. 顺便说一句。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

You'll need to use z-index to set the layering, something like this: 您需要使用z-index来设置分层,如下所示:

.menu {position:fixed; z-index:99999}
.content {position:relative; z-index:1}

Then you can fine tune it by using numbers in between. 然后,您可以使用之间的数字对其进行微调。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM