Bootstrap modal z-index

后端 未结 9 1338
时光说笑
时光说笑 2020-12-29 20:22

The issue is: I\'m using parrallx scrolling, so I have z-index in the page now when I try to popup a box-modal by Bootstrap I get him to look like this https://www.dropbox.c

9条回答
  •  失恋的感觉
    2020-12-29 21:16

    Well, despite of this entry being very old. I was using bootstrap's modal this week and came along this "issue". My solution was somehow a mix of everything, just posting it as it may help someone :)

    First check the Z-index war to get a fix there!

    The first thing you can do is deactivate the modal backdrop, I had the Stackoverflow post before but I lost it, so I wont take the credit for it, keep that in mind; but it goes like this in the HTML code:

    
    

    The second approach was to have an event listener attached to the bootstrap's shown modal event. This is somehow not so pretty as you may think but maybe with some tricks by your own may somehow work. The advantage of this is that the element attaches the event listener and you can completely forget about it as long as you have the event listener attached :)

    var element = $('selector-to-your-modal');
    
    // also taken from bootstrap 3 docs
    $(element).on('shown.bs.modal', function(e) {
      // keep in mind this only works as long as Bootstrap only supports 1 modal at a time, which is the case in Bootstrap 3 so far...
      var backDrop = $('.modal-backdrop');
      $(element).append($(backDrop));
    });

    The second.1 approach is basically the same than the previous but without the event listener.

    Hope it helps someone!

提交回复
热议问题