Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not allow the 'bounce' effect on the end of scrolling on a website?

Tags:

javascript

css

Im trying to get this scrolling effect i have seen on the website http://www.unheap.com , if you scroll to the bottom or to the right you'll notice that you can't scroll past whatsoever. Most website including this one allow you to scroll past slightly with a lot of resistance but I'm trying to replicate the example above where you can't scroll past at all. Anyone know of any plugins or methods on how to go about creating this effect?

like image 399
Oliver Klein Avatar asked Oct 14 '25 15:10

Oliver Klein


2 Answers

The actual website itself is 100% the width and height of the page and any scrolling that occurs is accomplished via an absolutely positioned container with overflow: scroll.

EDIT

The actual overflow is set on the .grid element, which is inside the absolutely positioned .container element.

EDIT #2

The author is also using jScrollPane, but you can prevent the bouncing effect simply by making your body 100% width and height and absolutely positioning a container that has overflow set to scroll.

EDIT #3 See the attached code snippet - (you may have to copy and paste it into it's own HTML file because of the way SO displays snippets). There is no bouncing.

* { margin:0; padding:0; }
html,
body { width: 100%; height: 100%; overflow:hidden;}
body>div { height: 50vh; overflow: auto; padding: 10px; background: #000; position: absolute; width: 100px; top: 100px; left: 100px;}
body>div>div { height: 1000px; background: #0f0;}
<div>
  <div>scrollable content</div>
  </div>
like image 145
Adam Avatar answered Oct 17 '25 04:10

Adam


add this line into your global.css

  • { overscroll-behavior: none; }
like image 33
Lim Avatar answered Oct 17 '25 05:10

Lim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!