Created
February 26, 2020 17:14
-
-
Save dexcell/498c16edc3b6022db841064e4e1142c4 to your computer and use it in GitHub Desktop.
Bootstrap 4 Stacked Modal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.modal').on('show.bs.modal', function () { | |
var $modal = $(this); | |
var baseZIndex = 1050; | |
var modalZIndex = baseZIndex + ($('.modal.show').length * 20); | |
var backdropZIndex = modalZIndex - 10; | |
$modal.css('z-index', modalZIndex).css('overflow', 'auto'); | |
$('.modal-backdrop.show:last').css('z-index', backdropZIndex); | |
}); | |
$('.modal').on('shown.bs.modal', function () { | |
var baseBackdropZIndex = 1040; | |
$('.modal-backdrop.show').each(function (i) { | |
$(this).css('z-index', baseBackdropZIndex + (i * 20)); | |
}); | |
}); | |
$('.modal').on('hide.bs.modal', function () { | |
var $modal = $(this); | |
$modal.css('z-index', ''); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment