Absolute position and Overflow:hidden

后端 未结 8 1099
暖寄归人
暖寄归人 2020-11-29 03:16
8条回答
  •  生来不讨喜
    2020-11-29 03:56

    It's completely impossible to do what you want with both overflow: hidden and position: relative on the parent div.. instead you can introduce an extra child div and move overflow: hidden to that.

    See: http://jsfiddle.net/thirtydot/TFTnU/

    HTML:

    sdfsd
    overflow "visible"

    CSS:

    #parent {
        position:relative;
        background:red;
        width:100px;
        height:100px
    }
    #child {
        position:absolute;
        background:#f0f;
        width:300px;
        bottom: 0;
        left: 0
    }
    #hideOverflow {
        overflow: hidden
    }
    

    #parent {
      position: relative;
      background: red;
      width: 100px;
      height: 100px
    }
    
    #child {
      position: absolute;
      background: #f0f;
      width: 300px;
      bottom: 0;
      left: 0
    }
    
    #hideOverflow {
      overflow: hidden
    }
    sdfsd
    overflow "visible"

提交回复
热议问题