Suppose you have some style and the markup:
ul
{
white-space: nowrap;
overflow-x: visible;
overflow-y: hidden;
/* added width so it would work in the snippet */
width: 100px;
}
li
{
display: inline-block;
}
<div>
<ul>
<li>1</li> <li>2</li> <li>3</li>
<li>4</li> <li>5</li> <li>6</li>
<li>7</li> <li>8</li> <li>9</li>
<li>1</li> <li>2</li> <li>3</li>
<li>4</li> <li>5</li> <li>6</li>
<li>7</li> <li>8</li> <li>9</li>
<li>1</li> <li>2</li> <li>3</li>
<li>4</li> <li>5</li> <li>6</li>
<li>7</li> <li>8</li> <li>9</li>
</ul>
</div>
When you view this. The <ul>
has a scroll bar at the bottom even though I've specified visible and hidden values for overflow x/y.
(observed on Chrome 11 and opera (?))
I'm guessing there must be some w3c spec or something telling this to happen but for the life of me I can't work out why.
UPDATE:- I found a way to acheive the same result by adding another element wrapped around the ul
. Check it out.
I've run into this issue when trying to build a fixed positioned sidebar with both vertically scrollable content and nested absolute positioned children to be displayed outside sidebar boundaries.
My approach consisted of separately apply:
overflow: visible
property to the sidebar elementoverflow-y: auto
property to sidebar inner wrapperPlease check the example below or an online codepen.
I used the
content+wrapper
approach ... but I did something different than mentioned so far: I made sure that my wrapper's boundaries did NOT line up with the content's boundaries in the direction that I wanted to be visible.Important NOTE: It was easy enough to get the
content+wrapper, same-bounds
approach to work on one browser or another depending on various css combinations ofposition
,overflow-*
, etc ... but I never could use that approach to get them all correct (Edge, Chrome, Safari, ...).But when I had something like:
... all browsers were happy.
another cheap hack, which seems to do the trick:
style="padding-bottom: 250px; margin-bottom: -250px;"
on the element where the vertical overflow is getting cutoff, with250
representing as many pixels as you need for your dropdown, etc.After some serious searching it seems i've found the answer to my question:
from: http://www.brunildo.org/test/Overflowxy2.html
also the W3C spec says:
Short Version:
If you are using
visible
for eitheroverflow-x
oroverflow-y
and something other thanvisible
for the other, thevisible
value is interpreted asauto
.There is now a new way of addressing this issue - if you remove position: relative from the container which needs to have the overflow-y visible, you can have overflow-y visible and overflow-x hidden, and vice versa (have overflow-x visible and overflow-y hidden, just make sure the container with the visible property is not relatively positioned).
See this post from CSS Tricks for more details - it worked for me: https://css-tricks.com/popping-hidden-overflow/
I originally found a CSS way to bypass this when using the Cycle jQuery plugin. Cycle uses JavaScript to set my slide to
overflow: hidden
, so when setting my pictures towidth: 100%
the pictures would look vertically cut, and so I forced them to be visible with!important
and to avoid showing the slide animation out of the box I setoverflow: hidden
to the container div of the slide. Hope it works for you.UPDATE - New Solution:
Original problem -> http://jsfiddle.net/xMddf/1/ (Even if I use
overflow-y: visible
it becomes "auto" and actually "scroll".)The new solution -> http://jsfiddle.net/xMddf/2/ (I found a workaround using a wrapper div to apply
overflow-x
andoverflow-y
to different DOM elements as James Khoury advised on the problem of combiningvisible
andhidden
to a single DOM element.)