Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

overflow-y:visible not working when overflow-x:hidden is present [duplicate]

Tags:

html

css

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?

like image 725
Seppo420 Avatar asked Jul 17 '12 10:07

Seppo420


People also ask

Why does overflow hidden not work?

It is because you are using position absolute. You cannot use position absolute with overflow hidden, because position absolute moves the targeted element out of context with the document structure.

What does overflow-Y Hidden do?

Definition and Usage The overflow-y property specifies whether to clip the content, add a scroll bar, or display overflow content of a block-level element, when it overflows at the top and bottom edges.


2 Answers

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.

like image 72
Sprintstar Avatar answered Sep 18 '22 04:09

Sprintstar


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> 
like image 23
ScottS Avatar answered Sep 19 '22 04:09

ScottS