简体   繁体   中英

Bootstrap 4 modal not focused when showing

I am using bootstrap 4 to show modal, I have a problem when click on the button to show it it's not appear as focused on the other page content . and that's what I am trying:

    <div class="add-advertise">
                <button type="button" data-toggle="modal" data-target="#advertiseModal" class="btn btn-primary">AddAdvertise</button>
            </div>
    <!-- The Modal -->
<div class="modal" id="advertiseModal">
    <div class="modal-dialog">
        <div class="modal-content">

            <!-- Modal Header -->
            <div class="modal-header">
                <h4 class="modal-title">Modal Heading</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>

            <!-- Modal body -->
            <div class="modal-body">
                Modal body..
            </div>

            <!-- Modal footer -->
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
            </div>

        </div>
    </div>
</div>

like this pic: 模态图像

how can I solve this problem?

Consider moving the modal to be a direct child under your body element.

From Sara Cope on CSS Tricks :

Also note that nesting plays a big role. If an element B sits on top of element A, a child element of element A can never be higher than element B.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM