Bootstrap Modal visible on document load

落花浮王杯 提交于 2019-12-02 06:02:10

问题


I have a Bootstrap Model working fine, except that it is visible when the document loads and I can't work out how to make the initial state invisible?

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>


<div class="modal" id="myModal" 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:


Following documentation, add hide class to the modal.

<div class="modal hide fade">
    ...
</div>



回答2:


Turns out simply adding style="display: none" to the modal outer div did the trick.



来源:https://stackoverflow.com/questions/12619519/bootstrap-modal-visible-on-document-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!