How to prevent get over other divs?

前端 未结 2 1235
傲寒
傲寒 2021-01-27 08:19

I have a problem...In the following example i don\'t want that the div who is fixed get over the div with the background red.

Here is the example:

http://jsfiddl

2条回答
  •  Happy的楠姐
    2021-01-27 08:35

    Just give the z-index.
    Hope it helps...

    http://jsfiddle.net/HFjU6/1/#run

    #fixedContainer {
      background-color:#ffffd;
      position: fixed;
      width: 200px;
      height: 100px;
      left: 50%;
      top: 0%;
      margin-left: -100px; /*half the width*/
      z-index: 2;
    }
    
    .div-red {
      position: relative;
      z-index: 5;
    }

提交回复
热议问题