CSS永远在最前面 [英] CSS Always On Top

查看:101
本文介绍了CSS永远在最前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的屏幕顶部有一个带有固定图像的网站.当我向下滚动页面时,图像会像应该的那样停留在顶部.但是,下面的所有内容都与我的图像重叠,然后被覆盖.

I have a website with a fixed image at the top of my screen. When I scroll down my page the image stays at the top like it should. However, all content below overlaps my image and it is then covered.

如何使顶部栏(图片)始终位于顶部?我希望它能在您滚动时覆盖页面的内容.

How do I make my top bar (image) always stay on top? I want it to cover the content of the page as you scroll.

推荐答案

确保position在元素上,并将z-index设置为高于要覆盖的元素的值.

Ensure position is on your element and set the z-index to a value higher than the elements you want to cover.

element {
    position: fixed;
    z-index: 999;
}

div {
    position: relative;
    z-index: 99;
}

这可能需要做更多的工作,但这是一个开始,因为您没有发布任何代码.

It will probably require some more work than that but it's a start since you didn't post any code.

这篇关于CSS永远在最前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆