模态文字不会显示

时间:2019-02-19 01:39:06

标签: javascript jquery html twitter-bootstrap bootstrap-modal

这些讨厌的模态又来了。我可以弹出我的模态,但是出于某些奇怪的原因,其正文中的文本没有显示。这是怎么回事?这是模态:

<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times; 
</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
       <p>Modal text.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>

1 个答案:

答案 0 :(得分:0)

也许是您正在使用的Bootstrap版本?

我只是将您的代码换成了Codepen上使用Bootstrap 4.0.0的现有对话框,它可以正常工作:

https://codepen.io/richjava/pen/JxxyWP

<!-- basic modal -->
<!-- <div class="modal fade" id="basicModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">Basic Modal</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <h3>Modal Body</h3>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div> -->

<div id="basicModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times; 
</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
       <p>Modal text.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>