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 ArticleAnswer by adardesign for Prevent BODY from scrolling when a modal is opened
Use body-scroll-lock Very light, very neat and popuplar
View ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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 ArticleAnswer 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