【发布时间】:2022-06-11 18:03:02
【问题描述】:
嗨,我试图在我的模式中禁用外部点击。我尝试过使用诸如背景:'静态',键盘:错误之类的方法,但我似乎无法使其工作
html:
<div class="container my-5">
<hr class="my-5">
<!-- Modal -->
<div class="modal fade" id="basicExampleModal" tabindex="-1" role="dialog" aria-
labelledby="exampleModalLabel" aria-hidden="true" data-backdrop="static" data-
keyboard="false">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<center><h1 class="modal-title" id="exampleModalLabel">Want more?</h1></center>
</button>
</div>
<div class="modal-body">
<strong>Create an account or Log in to see additional search results...</strong>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Sign up</button>
<button type="button" class="btn btn-primary">Log In</button>
</div>
</div>
</div>
</div>
javascript:
$(function() {
$('#basicExampleModal').modal('show');
});
【问题讨论】:
-
我在你的代码中没有看到任何模式jsfiddle.net/0y395mbr你能解释一下到底出了什么问题吗?
-
@MFerguson 我正在尝试禁用外部点击(关闭模式)我希望模式阻止用户使用页面,除非使用建议的按钮
-
The center element is deprecated。不要使用它。 Bootstrap 提供了几种方法来使事物居中,因此您无论如何都不需要它。
标签: javascript html twitter-bootstrap modal-dialog