Why does “overflow-y:hidden” affect the visibility of items overflowing on the x axis?

后端 未结 2 1277
野趣味
野趣味 2021-02-03 22:45

Consider this example:

http://jsfiddle.net/treeface/P8JbW/

HTML:

2条回答
  •  悲&欢浪女
    2021-02-03 23:33

    overflow is intended to be used with elements that are not absolutely positioned. If you want to handle the clipping of an absolutely positioned element, use the clip css property. So to clip on the bottom and top of your containing div, but not the left or right, do this:

    #test {
        position:relative;
        margin-left:50px;
        margin-top:50px;
        border:1px solid black;
        height:50px;
        width:50px;
        clip: rect(auto,auto,auto,-11px);
    }
    

    Sample: http://jsfiddle.net/treeface/UJNcf/6/

提交回复
热议问题