0

I want to design notification like facebook. In facebook I see scroll in notification dropdown, but not scroll in body. Here is my screenshot of notification.

enter image description here

When i scroll in notification, body also move up and down. how can i stop this? Please see my working fiddle When i scroll in red area my hole body will scroll. but i want that, When i scroll in red area, then body will not scroll.

<div style="width: 200px; height: 100px; overflow-y: scroll;background-color:red;">
  test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br />
</div>
<div>
  test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br />
</div>
<div>
  test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br />
</div>
<div>
  test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br />
</div>
<div>
  test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br /> test
  <br />
</div>
Awesome Designer
  • 254
  • 1
  • 14

3 Answers3

2

To get your notifications to scroll, you need to add overflow-y: scroll to your notifications element.

There are ways to stop the body from scrolling whenever this dropdown is open, but that seems like a terrible idea.

Kris Selbekk
  • 7,438
  • 7
  • 46
  • 73
1

You can use the overflow-y: scroll in CSS

Here's a working sample of what you are expecting to implement

JSFiddle Demo

Hope this helps :)

PS - Don't use inline CSS in your production code though. It's just for demonstration purposes only

Sahan Serasinghe
  • 1,591
  • 20
  • 33
1

I got my answer please check below code

$('.noscroll').on( 'mousewheel DOMMouseScroll', function (e) { 

  var e0 = e.originalEvent;
  var delta = e0.wheelDelta || -e0.detail;

  this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
  e.preventDefault();  
});

JS fiddle

Awesome Designer
  • 254
  • 1
  • 14