54

Doesn't work properly in Chrome or Firefox. Is there any workaround to this?

   <!DOCTYPE html>
   <html>
   <head></head>
   <body>
    <h3>overflow-y:visible</h3>

    with overflow-x:hidden
    <div style="overflow-x:hidden;overflow-y:visible;width:100px;height:100px;   position:relative;background:#666;">
        <div style="top:20px;left:20px;    width:420px;height:420px;position:absolute;background:#420;">
        </div>
    </div>

    without overflow-x:hidden
    <div style="overflow-y:visible;width:100px;height:100px;position:relative;background:#666;">
        <div style="top:20px;left:20px; width:420px;height:420px;position:absolute;background:#420;">
        </div>
    </div>

   </body>
   </html>

http://jsfiddle.net/sMNyK/

The real life scenario involves components that absolutely must have overflow-x:hidden, but that will trigger popup-menus that need to be able to break free from the element in y-direction. Should I just position those menus outside their parent components, or is there a better fix?

Seppo420
  • 2,041
  • 2
  • 18
  • 37

2 Answers2

51

This likely has to do with the issue addressed here: CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue

In short, when using visible for either overflow-x or overflow-y and something other than visible for the other, the visible value is interpreted as auto.

Community
  • 1
  • 1
Sprintstar
  • 7,938
  • 5
  • 38
  • 51
4

I think you can get what you want with an extra wrapping div that does the hiding but does not have the position: relative set (see fiddle):

<div style="overflow-y:visible;width:100px;height:100px;position:relative;background:#666;">
    <div style="overflow-x:hidden">
    ooooooooooooooooooooooooooooooooooooooooooooooo  
        <div style="top:20px;left:20px; width:420px;height:420px;position:absolute;background:#420;">
        </div>
    </div>
</div>
ScottS
  • 71,703
  • 13
  • 126
  • 146
  • 1
    This won't work, since the components requiring overflow-y:visible are inside the ones requiring overflow-x:hidden – Seppo420 Jul 17 '12 at 12:29
  • @user1185421--First, you said in your question that putting them "outside the parent components" was perhaps the only option. My solution should work as long as those components requiring `overflow-x:hidden` do not have a `position` set on them. This will allow the `absolute` element to relate only to the div that is `overflow-y: visible`. – ScottS Jul 17 '12 at 12:37
  • 2
    @user1185421--[here's a fiddle](http://jsfiddle.net/sMNyK/4/) with a wide `div` containing the pop-out div. – ScottS Jul 17 '12 at 12:39
  • You saved my day, Scotts! Thanks a lot! – Peter Babukh Mar 19 '20 at 18:52