CSS Sticky header

假如想象 提交于 2019-12-05 10:20:40

Add this code.. Add z-index:1000 in both #header_container & z-index:1001 in #header styles

 #header_container 
      { 
        position:fixed;
        top:0px;
        left:0px;
        z-index:1000;
       }

 #header{
      z-index:1001;
      }

Just use z-index parameter. For example z-index: 2 (present the order of the layer) It's available only for elements that use position: absolute, relative or fixed

W3schools example: http://www.w3schools.com/cssref/pr_pos_z-index.asp

Sent from iphone

<style type="text/css">
body{
    margin:0px;
    background:#000;
}
.header-cont {
    width:100%;
    position:fixed;
    top:0px;
}
.header {
    height:50px;
    background:#F0F0F0;
    border:1px solid #CCC;
    width:960px;
    margin:0px auto;
}
.content {
    width:960px;
    background: #F0F0F0;
    border: 1px solid #CCC;
    height: 2000px;
    margin: 70px auto;
}
</style>
</head>
<body>

<div class="header-cont">
    <div></div>
</div>

<div></div>

Click here to Check this best link for Sticky header using css

To your header add:

position:absolute;
z-index:9999;

This will lift it above everything else

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!