z-index not working with fixed positioning

后端 未结 8 1272
广开言路
广开言路 2020-11-22 03:46

I have a div with default positioning (i.e. position:static) and a div with a fixed position.

If I set the z-index

8条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 04:18

    Add position: relative; to #over

        #over {
          width: 600px;
          z-index: 10;
          position: relative;    
        }
        
        #under {
          position: fixed;
          top: 5px;
          width: 420px;
          left: 20px;
          border: 1px solid;
          height: 10%;
          background: #fff;
          z-index: 1;
        }
        
        
        
        	
    Hello Hello HelloHelloHelloHelloHello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello

    Fiddle

提交回复
热议问题