[英]Modal backdrop not shown using Bootstrap modal
I am using the modal plugin from Bootstrap and for some reason the backdrop is not showing.我正在使用 Bootstrap 的模态插件,但由于某种原因没有显示背景。
When I check same code on W3Schools I notice a div
is generated every time a modal opens:当我在 W3Schools 上检查相同的代码时,我注意到每次打开模态时都会生成一个
div
:
<div class="modal-backdrop fade in"></div>
I got the exact same code as on W3Schools but this div
is not generated on my site.我得到了与 W3Schools 完全相同的代码,但是这个
div
不是在我的网站上生成的。
How can I fix that?我该如何解决?
This happened to me when I used the wrong method to open the modal.当我使用错误的方法打开模态时,这发生在我身上。 I had
我有
$('#myModal').show()
when of course it should be当然应该是什么时候
$('#myModal').modal('show')
Another symptom of using the wrong method, in addition to the semi-opaque backdrop not showing, was the close button in the modal also did not work.使用错误方法的另一个症状,除了没有显示半透明背景外,模态中的关闭按钮也不起作用。
Please check whether CSS properties are overridden or not by inspecting <div class="modal-backdrop fade in"></div>
element.请通过检查
<div class="modal-backdrop fade in"></div>
元素来检查 CSS 属性是否被覆盖。 Mostly this could be a CSS issue caused by an override.大多数情况下,这可能是由覆盖引起的 CSS 问题。
Cannot reproduce this, as the w3 school examples work fine.无法重现这一点,因为 w3 学校示例工作正常。
Verify the following.验证以下内容。 This might cause the issue:
这可能会导致问题:
<div class="modal">..
at the end of the file or before </body>
<div class="modal">..
放在文件末尾或</body>
之前是一个好习惯Get the modal from http://getbootstrap.com/javascript/#modals-examples从http://getbootstrap.com/javascript/#modals-examples获取模态
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.