Absolute position and Overflow:hidden

后端 未结 8 1102
暖寄归人
暖寄归人 2020-11-29 03:16
8条回答
  •  甜味超标
    2020-11-29 03:47

    thirtydot's solution is actually a good idea.

    Here's a clearer example: http://jsfiddle.net/y9dtL68d/

    HTML

    this has a lot of content which ...

    this has a lot of content which ...

    this has a lot of content which ...

    this has a lot of content which ...

    this has a lot of content which ...

    this has a lot of content which ...

    this has a lot of content which ...

    dudes

    CSS

    #grandparent {
        position: relative;
        width: 150px;
        height: 150px;
        margin: 20px;
        background: #d0d0d0;
    }
    #parent {
        width: 150px;
        height: 150px;
        overflow:hidden;
    }
    #child {
        position: absolute;
        background: red;
        color: white;
        left: 100%;
        top: 0;
    }
    

提交回复
热议问题