How to not display child div when outside parent div border

后端 未结 3 346
轻奢々
轻奢々 2021-01-26 01:00

I\'m trying to get a child div to not display when it overextends its parent\'s boundaries.
Like this:

The child div (red border)

相关标签:
3条回答
  • 2021-01-26 01:33

    try to use this style:

    #contain{
      width:300px;
      height:200px;
      border:1px blue dashed;
      background-color:rgba(60, 10, 10, .5);
      padding:20px;
      overflow:hidden;
    }
    
    0 讨论(0)
  • 2021-01-26 01:33

    Add overflow: hidden; to the parent div.

    #contain{
      width:300px;
      height:200px;
      border:1px blue dashed;
      background-color:rgba(60, 10, 10, .5);
      padding:20px;
      overflow:hidden;
    }
    
    #big{
      width:500px;
      height:300px;
      border:1px red solid;
      background-color:rgba(30, 30, 30, .5);
    }
    <div id='contain'>
      <div id='big'>
    
      </div>
    </div>

    0 讨论(0)
  • 2021-01-26 01:41

    just add overflow:hidden; to your style.

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