html css header,html - CSS Sticky header - Stack Overflow

在网页设计中,作者遇到了固定头部(sticky header)在滚动时被内容覆盖的问题。代码显示了头部和底部的样式设置,但似乎缺少了确保内容区域在头部之上的CSS规则。解决方案可能涉及调整`z-index`属性,以确保头部在内容之上。
摘要由CSDN通过智能技术生成

I have added a sticky header to my homepage, however the sticky header seems to be behind the rest of the content on the page, so when i scroll down the page, images and text are on top of the header, is there a way to stop this?

Here is my code:

/* Reset body padding and margins */

body

{

margin: 0;

padding: 0;

}

/* Make Header Sticky */

#header_container

{

background: #827878;

border: 1px solid #666;

height: 60px;

left: 0;

position: fixed;

width: 100%;

top: 0;

}

#header

{

line-height: 60px;

margin: 10 auto;

width: 940px;

text-align: left;

font-size: 26px;

color: #f5f5f5;

line-height: 28px;

margin-bottom: 14px;

font-family: 'Source Sans Pro',sans-serif;

}

/* CSS for the content of page. I am giving top and bottom

padding of 80px to make sure the header and footer

do not overlap the content. */

#container

{

margin: 0 auto;

overflow: auto;

padding: 80px 0;

width: 940px;

}

#content

{

}

/* Make Footer Sticky */

#footer_container

{

background: #eee;

border: 1px solid #666;

bottom: 0;

height: 60px;

left: 0;

position: fixed;

width: 100%;

}

#footer

{

line-height: 60px;

margin: 0 auto;

width: 940px;

text-align: center;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值