我希望关闭我的模式,点击背景。为此,我想使用数据属性数据背景,如下所示:
<div id="myModal" class="modal fade" role="dialog" data-backdrop="">
<div class="modal-dialog">
<div class="modal-content">
<a class="link">
<img src="URL" />
</a>
</div>
</div>
</div>
哪里有问题?
感谢您的关注。
答案 0 :(得分:3)
因为您必须使用data-backdrop="true"
查看此bootply :http://www.bootply.com/kDYLtTapC4
HTML :
<a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Launch demo modal</a>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="true"> // <----- HERE
<div class="modal-dialog">
<div class="modal-content">
<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>
</div>
</div>