How to Overlap Parent Div From Child Div

前端 未结 5 1335
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 23:40

I have some divs at my HTML and one of them is loading image div so I want it overlap its parent div. Here is my code:

<
5条回答
  •  鱼传尺愫
    2021-01-03 00:14

    HTML

    CSS

    #parent { 
      width: 100px;
      height: 300px;
      background-color: #a0a0a0;
      width:200px;
      height:250px;
      position: relative;
    }
    
    #child {
      width: inherit;
      height: inherit;
      position: absolute;
      background-color: #a2f2e2;
      top: 0px;
      left: 0px;
    }
    

    Works fine

    EDIT: added with and height inherit for you & positioned properly

提交回复
热议问题