Why z-index is not working?

前端 未结 2 1179
梦如初夏
梦如初夏 2020-12-22 07:41

I have this HTML code:

Title goes here

&
相关标签:
2条回答
  • 2020-12-22 07:58

    I think you have some max height/width, so just write some CSS to #logo

    #logo {
        position: absolute;
        z-index: 1;
        width: 100px; /* your maximum in width */
        height: 100px; /* your maximum in height */
        overflow: hidden; /* just to make sure there is nothing leaking your DIV */
    }
    
    0 讨论(0)
  • 2020-12-22 08:03

    Just manually set the #right-block position :

    #right-block {
        position: relative;
        float: right;
        background-color: blue;
        height: 50px;
        z-index: 5;
    }
    

    z-index only woks on absolute|relative|fixed positioned elements, and the default value is for position is static.

    0 讨论(0)
提交回复
热议问题