Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scrollTop and html overflow: hidden

When a CSS rule is set like this

html { overflow: hidden; }

I can't get or set scroll position in Chrome using javascript anymore (only DOMElement.scrollIntoView is working).

When I remove it it works but it messes up the whole page containing a "parallax effect" created with CSS3. Here is a reduced example (only prefixed with -webkit-): http://jsfiddle.net/BaliBalo/LxCxn/

like image 241
Bali Balo Avatar asked Jan 24 '14 03:01

Bali Balo


People also ask

What is the difference between overflow scroll and overflow hidden?

hidden - The overflow is clipped, and the rest of the content will be invisible. scroll - The overflow is clipped, and a scrollbar is added to see the rest of the content.

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.

What is the opposite of overflow hidden?

hidden. The opposite of the default visible is hidden. This literally hides any content that extends beyond the box. This is particularly useful in use with dynamic content and the possibility of an overflow causing serious layout problems.

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.


1 Answers

You can do by using the clearfix to do "layout preversing" the same way overflow: hidden does.

.clearfix:before,
.clearfix:after {
  content: ".";    
  display: block;    
  height: 0;    
  overflow: hidden; 
}
.clearfix:after {clear: both;}
.clearfix {zoom: 1;} /* IE < 8 */

add class="clearfix" class to the parent, and remove overflow: hidden;

like image 129
HMagdy Avatar answered Sep 30 '22 21:09

HMagdy