Twitter Bootstrap - why is my modal as faded as the background?

北战南征 提交于 2019-12-04 23:59:04

Check this issue on the Bootstrap git repository.

Then try putting the modal before the navbar, like this fiddle.

<div id="registration_modal" class="modal hide fade">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Register An Account</h3>
    </div>

    <div class="modal-body">
        Registration form goes here.
    </div>

    <div class="modal-footer">
        <button class="btn btn-secondary" data-dismiss="modal">Cancel</button>
        <button class="btn btn-primary">Register</button>
    </div>

</div>
<div class="navbar navbar-fixed-top"> 
    <a href="#registration_modal" data-toggle="modal">
        Register
    </a>    
</div>

janeeats

Unfortunately the answer here didn't help me.. but fortunately this discussion has the same issue and they have a helpful answer that worked for me. Basically, you have to make sure the modal is not inheriting any weird positioning elements from parent divs:

Bootstrap modal appearing under background

The way that I solved it was by wrapping everything within the modal inside a <div class="modal-content"> tag. It looked something like this:

<div class="modal fade" id="TestModal">
    <div class="modal-content">
        <div class="modal-header">
            Modal header here
        </div>
        <div class="modal-body">
            <p>Modal content here</p>
        </div>
        <div class="modal-footer">
            <button class="btn btn-primary" data-dismiss="modal">Close</button>
        </div>
    </div>
</div>

Without the modal-content div, the modal ended up being just as gray as the the background.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!