Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS overflow-y:visible, overflow-x:scroll

Tags:

css

overflow

I've seen a few questions like this in my search, but either the question didn't get answered properly or no answer was given. So, I'll ask again.

<style> .parent { overflow-y:scroll; overflow-x:visible; width:100px; } .child { position:relative; } .child-menu { position:absolute; top:0px; left:-100px; display:inline-block; } </style>    <div class="parent">   <!-- Lots of the following divs -->   <div class="child">     Text Line     <div class="child-menu">some pop out stuff</div>   </div> </div> 

Alright, that's just an example. But basically, what I'm trying to accomplish is have the .child classes be scrollable on the y axis...scroll up and down. But I want the x-axis....the child-menu's to be visible outside the .parent container.

Does that make sense? So what is happening is that when the page renders, the browser is interpreting the overflow as auto altogether and not respecting the separate axis. Am I doing something wrong or are the browsers just not up to CSS3 spec yet on this? Mostly only tested on Chrome. enter image description here

like image 473
Senica Gonzalez Avatar asked Mar 06 '11 08:03

Senica Gonzalez


People also ask

What is overflow-y and overflow-X?

overflow-x specifies what to do with the left/right edges of the content. overflow-y specifies what to do with the top/bottom edges of the content. You can use the overflow property when you want to have better control of the layout. The overflow property specifies what happens if content overflows an element's box.

What is overflow-x scroll?

The overflow-x CSS property sets what shows when content overflows a block-level element's left and right edges. This may be nothing, a scroll bar, or the overflow content.

How do I show scroll only when overflow?

Use overflow: auto . Scrollbars will only appear when needed. (Sidenote, you can also specify for only the x, or y scrollbar: overflow-x: auto and overflow-y: auto ).


2 Answers

I figured it out!

The parent should be overflow:auto; The .child should be position:relative; The .child-menu should be position:fixed; with NO top or left positioning. If you do this, it will keep it it inline with the content.

If you need to move the child-menu use margins and not top or left. Example margin-left:-100px;

EDIT

As it seems people still use this, please note that you will have to use javascript to move the fixed items as the page scrolls.

like image 145
Senica Gonzalez Avatar answered Sep 17 '22 12:09

Senica Gonzalez


It solved here! They use css and JS.

.child:hover .child-menu { display: block; }   .parent { overflow-y:auto; overflow-x:hidden; width:100px; height:150px  }     .child { position:static; }     .child-menu { position:absolute; display:inline-block; display: none; } 

https://css-tricks.com/popping-hidden-overflow/

https://jsfiddle.net/68fBE/2/

like image 33
blondo Avatar answered Sep 16 '22 12:09

blondo