Just move the entire modal outside of the rest of your code, to the very bottom. It doesn't need to be nested in any other element, other than the body.
<body>
<!-- All other HTML -->
<div>
...
</div>
<!-- Modal -->
<div class="modal fade" id="myModal">
...
</div>
</body>
Demo
They hint at this solution in the documentation.
Answer from Schmalzy on Stack OverflowModal Markup Placement
Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's appearance and/or functionality.
Just move the entire modal outside of the rest of your code, to the very bottom. It doesn't need to be nested in any other element, other than the body.
<body>
<!-- All other HTML -->
<div>
...
</div>
<!-- Modal -->
<div class="modal fade" id="myModal">
...
</div>
</body>
Demo
They hint at this solution in the documentation.
Modal Markup Placement
Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's appearance and/or functionality.
In my case, I could fix it by adding css for the .modal-backdrop
.modal-backdrop {
z-index: -1;
}
Although this works, form controls still seem to appear above the backdrop, clicking anywhere dismisses the modal, but it doesn't look great.
A better workaround for me is to bind to the shown event (once the page is loaded) and to correct the z-index property.
$('.modal').on('shown.bs.modal', function() {
$(this).css("z-index", parseInt($('.modal-backdrop').css('z-index')) + 1);
});
In this case, if you are OK with changing the DOM on modal shown:
$('.modal').on('shown.bs.modal', function() {
//Make sure the modal and backdrop are siblings (changes the DOM)
$(this).before($('.modal-backdrop'));
//Make sure the z-index is higher than the backdrop
$(this).css("z-index", parseInt($('.modal-backdrop').css('z-index')) + 1);
});
X
· · · · Close · · · · Here's the jQuery for the modal window. · · Here's the css: · .page-overlay{ · position:fixed; · left: 0px; · top: 0px; · height: 100%; · width:100%; · background: rgba(0, 0, 0, 0.5); · z-index: 200; · .lightbox-wrapper { · width: 70%; · margin: 0 auto; · .lightbox-content { · position: relative; · top: 50%; · transform: translateY(-50%); · background-color: #fff; · text-align: center; · border-radius: 7px; · padding: 25px; · -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3); · -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3); · box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3); · overflow: hidden; · .lightbox-content img { · max-width: 100%; · height: auto; · .close-lightbox { · position: absolute; · right: 25px; · top: 15px; · padding: 10px 0 10px 0; · margin: 0; · color: #AFAFAF; · .append-content h4 { · padding: 0 0 25px 0; · font-weight: 400; · @media only screen and (max-width : 768px) { · #lightbox-wrapper { · width: 90%; · .btn-default { · float: right; · margin: 20px 0 0 0; · background: rgba(0, 0, 0, 0.2); · .btn-default:hover { · background: #FF864C; · color: #fff; · Here is your Black Vision link: ·