Bootstrap Modal visible on document load

2019-03-01 22:09发布

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>

2条回答
2楼-- · 2019-03-01 22:38

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

查看更多
太酷不给撩
3楼-- · 2019-03-01 22:44

Following documentation, add hide class to the modal.

<div class="modal hide fade">
    ...
</div>
查看更多
登录 后发表回答