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

jononomo picture jononomo · Nov 13, 2012 · Viewed 26.3k times · Source

So I'm using Twitter Bootstrap and I have a modal that slides down when the user clicks the "Register" button.

The only problem is that the not only does the background page fade, which is a nice effect, but the modal is also faded. How can I get it so that the modal is normal brightness while the background is faded?

I created a JSFiddle to demonstrate my problem here: http://jsfiddle.net/jononomo/7z8RZ/7/

The following code creates a faded modal:

<div class="navbar navbar-fixed-top"> 
    <a href="#registration_modal" data-toggle="modal">
        Register
    </a>
    <div id="registration_modal" class="modal hide fade">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">×</button>
                <h3 id="myModalLabel">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>

Note: if I remove the outer div, then everything works fine. So the problem is that the code for the modal is within the following lines:

<div class="navbar navbar-fixed-top">
</div>

Of course I don't want to remove that div, since I want the button the link that launches the modal to be in the navbar that is fixed to the top of the screen.

Edit: I have narrowed it down to the fact that the outer div is of the class navbar-fixed-top. When I remove that tag, everything works as expected -- you can see it working correctly here: http://jsfiddle.net/jononomo/7z8RZ/8/ Of course, I would like the navbar to be fixed to the top, so this doesn't solve my problem.

Answer

crowjonah picture crowjonah · Nov 13, 2012

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>