Quantcast
Channel: Prevent BODY from scrolling when a modal is opened - Stack Overflow
Browsing all 60 articles
Browse latest View live

Answer by LowFieldTheory for Prevent BODY from scrolling when a modal is opened

Since for me this problem presented mainly on iOS, I provide the code to fix that only on iOS: if(!!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform)) { var $modalRep =...

View Article


Answer by adardesign for Prevent BODY from scrolling when a modal is opened

Use body-scroll-lock Very light, very neat and popuplar

View Article


Answer by app developer 27 for Prevent BODY from scrolling when a modal is...

What finally fixed this for me was Body scroll lock . Other solutions don't disable scrolling on iOS.

View Article

Answer by nrkz for Prevent BODY from scrolling when a modal is opened

Why not to do that as Bulma does? When modal is-active then add to html their class .is-clipped which is overflow: hidden!important; And thats it. Edit: Okey, Bulma has this bug, so you must add also...

View Article

Answer by user1095118 for Prevent BODY from scrolling when a modal is opened

As of November 2017 Chrome Introduced a new css property overscroll-behavior: contain; which solves this problem although as of writing has limited cross browser support. see below links for full...

View Article


Answer by Danie for Prevent BODY from scrolling when a modal is opened

Many suggest "overflow: hidden" on the body, which will not work (not in my case at least), since it will make the website scroll to the top. This is the solution that works for me (both on mobile...

View Article

Answer by George Siggouroglou for Prevent BODY from scrolling when a modal is...

The above occurs when you use a modal inside another modal. When I open a modal inside another modal, the closing of the latter removes the class modal-open from the body. The fix of the issue depends...

View Article

Image may be NSFW.
Clik here to view.

Answer by Bocard Wang for Prevent BODY from scrolling when a modal is opened

Sadly none of the answers above fixed my issues. In my situation, the web page originally has a scroll bar. Whenever I click the modal, the scroll bar won't disappear and the header will move to right...

View Article


Answer by namal for Prevent BODY from scrolling when a modal is opened

worked for me $('#myModal').on({'mousewheel': function(e) { if (e.target.id == 'el') return; e.preventDefault(); e.stopPropagation(); } });

View Article


Answer by Lozhachevskaya Anastasiya for Prevent BODY from scrolling when a...

I had a sidebar that was generated by checkbox hack. But the main idea is to save the document scrollTop and not to change it during scrolling the window. I just didn't like the page jumping when body...

View Article

Answer by Kristian for Prevent BODY from scrolling when a modal is opened

A small note for those in SharePoint 2013. The body already has overflow: hidden. What you are looking for is to set overflow: hidden on div element with id s4-workspace, e.g. var body =...

View Article

Answer by Murat Yıldız for Prevent BODY from scrolling when a modal is opened

For Bootstrap, you might try this (working on Firefox, Chrome and Microsoft Edge) : body.modal-open { overflow: hidden; position:fixed; width: 100%; } Hope this helps...

View Article

Answer by Jassim Abdul Latheef for Prevent BODY from scrolling when a modal...

Adding the class 'is-modal-open' or modifying style of body tag with javascript is okay and it will work as supposed to. But the problem we gonna face is when the body becomes overflow:hidden, it will...

View Article


Answer by ling for Prevent BODY from scrolling when a modal is opened

Based on this fiddle: http://jsfiddle.net/dh834zgw/1/ the following snippet (using jquery) will disable the window scroll: var curScrollTop = $(window).scrollTop();...

View Article

Answer by Mats for Prevent BODY from scrolling when a modal is opened

If modal are 100% height/width "mouseenter/leave" will work to easily enable/disable scrolling. This really worked out for me: var currentScroll=0; function lockscroll(){...

View Article


Answer by Fernando Siqueira for Prevent BODY from scrolling when a modal is...

$('.modal').on('shown.bs.modal', function (e) { $('body').css('overflow-y', 'hidden'); }); $('.modal').on('hidden.bs.modal', function (e) { $('body').css('overflow-y', ''); });

View Article

Answer by Afonso for Prevent BODY from scrolling when a modal is opened

You should add overflow: hidden in HTML for a better cross-platform performance. I would use html.no-scroll { overflow: hidden; }

View Article


Answer by AdamJB for Prevent BODY from scrolling when a modal is opened

I'm not 100% sure this will work with Bootstrap but worth a try - it worked with Remodal.js which can be found on github: http://vodkabears.github.io/remodal/ and it would make sense for the methods to...

View Article

Answer by Hopeful Man for Prevent BODY from scrolling when a modal is opened

This issue is fixed, Solution: Just open your bootstap.css and change as below body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom { margin-right: 15px; } to...

View Article

Answer by Cliff for Prevent BODY from scrolling when a modal is opened

I just done it this way ... $('body').css('overflow', 'hidden'); But when the scroller dissapeared it moved everything right 20px, so i added $('body').css('margin-right', '20px'); straight after it....

View Article
Browsing all 60 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>