Why z-index is not working for div?

后端 未结 4 1867
我在风中等你
我在风中等你 2021-02-05 08:01

I am trying to get my footer to show on top of the footer background, but z-index seems not to be working. Does anyone see what is wrong with it? http://jsfiddle.net/f2ySC/

4条回答
  •  走了就别回头了
    2021-02-05 08:13

    You have to explicitly define the position property:

    .footerBox {
        background-color: #FFFFFF;
        border: 10px solid #DDDDDD;
        margin: 10px 0 -200px -10px;
        width: 1185px;
        z-index: 1000;
    
        position:relative;
    
    }
    

    http://jsfiddle.net/f2ySC/1/


    This brings the footer into the current stacking context:

    ... The root element forms the root stacking context. Other stacking contexts are generated by any positioned element (including relatively positioned elements) having a computed value of 'z-index' other than 'auto'. Stacking contexts are not necessarily related to containing blocks. In future levels of CSS, other properties may introduce stacking contexts, for example 'opacity' ...

    http://www.w3.org/TR/CSS2/visuren.html#z-index

提交回复
热议问题