Displaying one div on top of another

后端 未结 5 1602
说谎
说谎 2020-12-13 04:13

I have some HTML with two divs:

\"\"
5条回答
  •  时光说笑
    2020-12-13 05:10

    To properly display one div on top of another, we need to use the property position as follows:

    • External div: position: relative
    • Internal div: position: absolute

    I found a good example here:

    .dvContainer {
      position: relative;
      display: inline-block;
      width: 300px;
      height: 200px;
      background-color: #ccc;
    }
    
    .dvInsideTL {
      position: absolute;
      left: 0;
      top: 0;
      width: 150px;
      height: 100px;
      background-color: #ff751a;
      opacity: 0.5;
    }
    Top Left Top Right
    Bottom Left Bottom Right

    I hope this helps,
    Zag.

提交回复
热议问题