Search code examples
javascriptjqueryhtmltwitter-bootstrapbootstrap-modal

Scrolling issues with multiple bootstrap modals


I have a page with a modal with a lot of info so you need to scroll. This modal contains a link to a second modal.

When I

  • open modal 1
  • click on link to open modal 2 (modal 1 stays in background)
  • and then close modal 2 so that I am back on modal 1

modal 1 looses scrolling (there is still a scroll bar but it doesn't do anything). Instead the modal stays in the position it was at the time of opening modal 2.

I played around with closing the background modal with js first (but that messes up scrolling on the second modal). It appears that every time I try to open/close more than one modal I always get some issue with the scrolling.

Any suggestions on how to handle this?


Solution

  • Add

    .modal { overflow: auto !important; }
    

    To your CSS.

    Without your code I went ahead and created this jsFiddle that recreates your issue, or at least a very similar one. Add your code and I will test if this works or not.

    Adding that line to the CSS fixed the issue as demonstrated with this jsFiddle.

    Solution taken from this thread on github which offers other solutions as well.