我正在尝试在模态主体内创建一个表,但该表显示的比模态更大。



$('#myModal').modal('show');

<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>



<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
  <div class="modal-dialog">

    <div class="modal-content">

      <div class="modal-header">
        <button aria-hidden="true" data-dismiss="modal" class="close" type="button">X</button>
        <h4 id="infoTitleText" class="modal-title"><strong>Test</strong></h4>
      </div>

      <div class="modal-body">
        <table>
          <thead>
          </thead>
          <tbody>
            <tr>
              <td colspan="4" align="center">
                <p>Paragraph message</p>
              </td>
            </tr>
            <tr>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image1" /></td>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image2" /></td>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image3" /></td>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image4" /></td>
            </tr>
          </tbody>
        </table>
      </div>

      <div class="modal-footer">
        <button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
        <button data-dismiss="modal" class="btn btn-primary" type="button">Confirm</button>
      </div>

    </div>
  </div>





有人知道我在做什么错吗?我正在尝试将表格放在模态内。

最佳答案

一个快速的解决方法是对图像使用max-width或不使用表格,但是一些响应式设计技术...-完全取决于您的需求...可以了



$('#myModal').modal('show');

.modal-body table img {
  max-width: 100%;
}

<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>



<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
  <div class="modal-dialog">

    <div class="modal-content">

      <div class="modal-header">
        <button aria-hidden="true" data-dismiss="modal" class="close" type="button">X</button>
        <h4 id="infoTitleText" class="modal-title"><strong>Test</strong></h4>
      </div>

      <div class="modal-body">
        <table>
          <thead>
          </thead>
          <tbody>
            <tr>
              <td colspan="4" align="center">
                <p>Paragraph message</p>
              </td>
            </tr>
            <tr>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image1" /></td>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image2" /></td>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image3" /></td>
              <td><img src="//placehold.it/300x50/0bf" height="30" alt="image4" /></td>
            </tr>
          </tbody>
        </table>
      </div>

      <div class="modal-footer">
        <button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
        <button data-dismiss="modal" class="btn btn-primary" type="button">Confirm</button>
      </div>

    </div>
  </div>

关于jquery - table 比模体大,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48511609/

10-12 01:15