Why does “overflow-y:hidden” affect the visibility of items overflowing on the x axis?
考虑以下示例:
http://jsfiddle.net/treeface/P8JbW/
HTML:
1 | <img src="http://ycombinator.com/images/y18.gif" /> |
CSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #test { position:relative; margin-left:50px; margin-top:50px; border:1px solid black; height:50px; width:50px; overflow-x:visible; overflow-y:hidden; } img { position:absolute; left:-11px; } |
我希望看到这个:
但是我得到这个:
似乎在这里overflow-x属性被覆盖。 那是实际情况吗? 假设我必须将overflow-y设置为隐藏,是否可以解决此问题?
1 2 3 4 5 6 7 8 9 | #test { position:relative; margin-left:50px; margin-top:50px; border:1px solid black; height:50px; width:50px; clip: rect(auto,auto,auto,-11px); } |
范例:http://jsfiddle.net/treeface/UJNcf/6/
根据CSS3规范:
The computed values of
overflow-x andoverflow-y are the same as their specified values, except that some combinations withvisible are not possible: if one is specified asvisible and the other isscroll orauto , thenvisible is set toauto . The computed value ofoverflow is equal to the computed value ofoverflow-x ifoverflow-y is the same; otherwise it is the pair of computed values ofoverflow-x andoverflow-y .
由此看来,