Hide scrollable content behind transparent fixed position divs when scrolling the page?

后端 未结 10 1077
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 09:16

I have a div called header that is set up with a fixed position. The problem is when I scroll the page the content of the page shows up behind the header (the header is tran

10条回答
  •  误落风尘
    2020-12-01 10:02

    The header's z-index is set to 1000, so the z-index of the container would have to be 1001 if you want it to stack on top of the header. https://codepen.io/richiegarcia/pen/OJypzrL

    #header {
        margin:0 auto;
        position: fixed;
        width:100%;
        z-index:1000;
    }
    #topmenu {
        background-color:#0000FF;
        height:24px;
        filter: alpha(opacity=50);
        opacity: 0.5;
    }
    
    #leftlinks {
        padding: 4px;
        padding-left: 10px;
        float: left;
    }
    
    #rightlinks {
        padding: 4px;
        padding-right: 10px;
        float: right;
    }
    
    #containerfixedtop {
        width: 100%;
        height: 20px;
    }
    
    #contentfixedtop {
        margin: 0 auto;
        background-color: #DAA520;
        width: 960px;
        height:20px;
    }
    
    #container {
        position: relative;
        top: 68px;
        width: 100%;
        height: 2000px;
        overflow: auto;
        z-index:1001;
    }
    
    #content {
        margin: 0 auto;
        background-color: #DAA520;
        width: 960px;
        height: 2000px;
    }
    

提交回复
热议问题