Bootstrap Modal opens but stays in gray background and cannot close or interact with modal

Dan

I am using Bootstrap's Modal class to have a modal appear after clicking a button. The code works - the button is clicked and the modal appears, however, the whole screen is grayed-out and the modal cannot be clicked. I cannot close the modal since it is "in" the gray background. You can see in the image below: Modal in gray background

Here is the code:

    <!-- Modal -->
<div id="myModal" class="modal fade" style="z-index: 9999;" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
                <p>Some text in the modal.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
<section id="profileMain">
    <form class="formoid-solid-dark"
        style="background-color: #FFFFFF; font-size: 14px; font-family: 'Trebuchet MS','Roboto', Arial, Helvetica, sans-serif; color: #34495E; max-width: 800px; min-width: 150px"
        method="post" action="">
        <div class="title">
            <h2>Intake Request</h2>
        </div>
        <div id="mainFormTabs" class="container">
            <ul class="nav nav-pills">
                <li><a data-toggle="tab" href="#tabCM">Comments</a></li>
            </ul>
            <div class="container" style="border:1px solid #34495E; border-radius: 0px 4px 4px 4px;">
                <div class="tab-content clearfix" style="padding: 10px;">
                    <div id="tabCM" class="tab-pane fade">
                        <!-- Trigger the modal with a button -->
                        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>

I have tried adjusting the z-index for the modal, I have moved the modal div outside the body, at the top, and at the bottom of the html form, but none of these worked.

I appreciate any ideas on how to fix this.

Dan

I went back and moved the modal div outside the body tag and it is now working.

</body>
<!-- Modal -->
<div id="myModal" class="modal fade" style="z-index: 9999;" role="dialog">
    <div class="modal-dialog">
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
                <p>Some text in the modal.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related