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.
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:Without the
modal-content
div, the modal ended up being just as gray as the the background.Check this issue on the Bootstrap git repository.
Then try putting the modal before the navbar, like this fiddle.
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