问题
I'm using twitter bootstrap modal,when I click the link,still black fade appears on the modal.
FYI - https://docs.google.com/file/d/0B7s0BYiHsMBtY1pLdmVsclpQXzA/edit?usp=sharing
Here is my code:
<ul class="nav pull-right">
<li><a href="#myModal" data-target="#myModal" data-toggle="modal">Signin</a></li>
</ul>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
回答1:
I found an working example here:
JSFIDDLE
NOTE: when you want to hide the fade black just remove backdrop: true;
from the jquery.
HTML:
<div id="event-modal" class="modal hide fade">
<div class="modal-header">
<a class="close" href="#">x</a>
<h3>Modal Heading</h3>
</div>
<div class="modal-body">
<p>Some information</p>
</div>
<div class="modal-footer">
<a class="btn primary" href="#">Primary</a>
<a class="btn secondary" href="#">Secondary</a>
</div>
</div>
<a href="/events/2-fefewfewfe/rsvps" data-backdrop="true" data-controls-modal="event-modal" data-keyboard="true">I'm attending!<span class="ico join"></span></a>
JQUERY:
$(function() {
$('#event-modal').modal({
backdrop: true
});
});
CSS:
#event-modal {
margin-top: 0;
}
回答2:
This looks like CSS issue.
Check if something doesn't overwrite your modal z-index
property, by default modal has:
.modal {
z-index: 1050;
}
And backdrop:
.modal-backdrop {
z-index: 1040;
}
Modal should have higher value.
回答3:
Same code working fine for me.. Check your JS files were added properly or not..
Esp. bootstrap-modal.js, bootstrap-transition.js
check once this fiddle:
http://jsfiddle.net/7vyUQ/
<ul class="nav pull-right">
<li><a href="#myModal" data-target="#myModal" data-toggle="modal">Signin</a></li>
</ul>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
来源:https://stackoverflow.com/questions/15874225/twitter-bootstrap-modal-fade-black