Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overflow hidden, but still able to scroll (only Chrome)

I have a very strange CSS "bug".

I'm currently working on an slider thing (slides have form elements on them). When I click & drag (to the right to scroll horizontal) on an label within the slide, then the container scrolls and the next slide comes visible while the property overflow: hidden; is set on the container.

I found out that the overflow property works normal when there is NO label tag present.

Does anyone has a solution herefor? I tried a lot of CSS stuff but no success. I recreated the bug in JsFiddle here: clicky

Update

  • The click & drag bug thing appears only in Chrome. (I tested IE and FF)
  • Plus, it's NOT about the scroll bar of the ul list with the labels, but about the fact that you can click on an label and drag it to the right to scroll to the next slide.
like image 742
Sven van Zoelen Avatar asked Oct 12 '12 12:10

Sven van Zoelen


People also ask

Does overflow hidden prevent scrolling?

To prevent scrolling with this property, just apply the rule overflow: hidden to the body (for the entire page) or a container element. This hides all content beyond the element's border.

How do I scroll with overflow hidden?

Use overflow-x : scroll and overflow-y : hidden , or overflow: scroll hidden instead. Use overflow-x : hidden and overflow-y : scroll , or overflow: hidden scroll instead.

How do I show scroll only when overflow?

Add CSS. Set the overflow property to “auto”. This value adds scrollbar when the content overflows.

How can I hide scrollbar in iframe but still scroll?

1. Set the overflow of the parent div as hidden. 2. Set the overflow of the child div to auto and the width 200% (or anything more than 100%, or more than the width of the parent - so that the scrollbar gets hidden).


2 Answers

This is a known bug in Chromium (Google chrome is based on this) see: http://code.google.com/p/chromium/issues/detail?id=116655

Because both Safari and Chrome appear to show the issue I would hazard a guess that this bug is general to all webkit based browsers.

Unfortunately there has been no response from the Chromium development. I suggest you vote for this issue on the link provided to help see it resolved in future revisions.

like image 117
George Reith Avatar answered Oct 09 '22 00:10

George Reith


Here is a workaround using jQuery.

$(your_slider).scroll(function(){
    if($(this).scrollTop() != 0 ){
        $(this).scrollTop(0)
    }
});

If you are scrolling horizontally then replace scrollTop with scrollLeft

like image 44
James Fair Avatar answered Oct 09 '22 01:10

James Fair