Skip to content Skip to sidebar Skip to footer

Why Does "overflow-y:hidden" Affect The Visibility Of Items Overflowing On The X Axis?

Consider this example: http://jsfiddle.net/treeface/P8JbW/ HTML:
CSS: #test {

Solution 1:

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/

Solution 2:

From the CSS3 spec:

The computed values of overflow-x and overflow-y are the same as their specified values, except that some combinations with visible are not possible: if one is specified as visible and the other is scroll or auto, then visible is set to auto. The computed value of overflow is equal to the computed value of overflow-x if overflow-y is the same; otherwise it is the pair of computed values of overflow-x and overflow-y.

From this it would seem that some combinations of overflow-x & overflow-y are not valid, and sometimes one will override the other, which would explain what you're seeing here. Though I'm unsure as the wording as a bit unclear and the way browsers actually implement it could vary from the spec (especially when it's hard to decipher).

Post a Comment for "Why Does "overflow-y:hidden" Affect The Visibility Of Items Overflowing On The X Axis?"