html - 调整浏览器大小时 Bootstrap 表超出面板

标签 html css twitter-bootstrap multiple-columns

我正在尝试构建一个内部有表格的面板。代码如下所示:

<div class="container">
              <div class="row">
               <div class="panel panel-default col-xs-12">

             <div class="panel">
               <div class="panel-heading bg-primary">
                <h3 class="panel-title">This is a panel</h3>
              </div>

              <div class="panel-body">
                <p>What is Lorem Ipsum?
                 Lorem Ipsum is simply dummy text of the printing and  typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p.
              </div> <!-- panel body -->

                <!-- Table inside the panel -->
                <table class="table">
                  <thead>
                    <tr>
                      <th>Firstname</th>
                      <th>Lastname</th>
                      <th>Email</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td>John</td>
                      <td>Doe</td>
                      <td>john@example.com</td>
                    </tr>
                    <tr>
                      <td>Mary</td>
                      <td>Moe</td>
                      <td>mary@example.com</td>
                    </tr>
                    <tr>
                      <td>July</td>
                      <td>Dooley</td>
                      <td>july@example.com</td>
                    </tr>
                  </tbody>
                </table>
              </div> <!-- panel -->


          </div> <!-- row -->
        </div> <!-- container --> 

面板在大多数屏幕尺寸上看起来都不错,除了表格打破面板的移动屏幕。我不确定我做错了什么,因为该示例与 Bootstrap 网站上的示例非常相似,而且它似乎对所有屏幕尺寸都有响应。谢谢!

Table breaking the panel

最佳答案

尝试将 .table 包装在 table-responsive

包装panelcol-xs-12并从面板本身中删除 col 类(面板将始终跨越其父级的全宽)

包括 table在你的panel-body

我还注意到一个 <p> panel-body 中未关闭的标签:p

希望这对您有所帮助!

<div class="container">
  <div class="row">
    <div class="col-xs-12">
      <div class="panel panel-default">

        <div class="panel">
          <div class="panel-heading bg-primary">
            <h3 class="panel-title">This is a panel</h3>
          </div>

          <div class="panel-body">
            <p>What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
              make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
              passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

            <!-- Table inside the panel -->
            <div class="table-responsive">
              <table class="table">
                <thead>
                  <tr>
                    <th>Firstname</th>
                    <th>Lastname</th>
                    <th>Email</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>John</td>
                    <td>Doe</td>
                    <td>john@example.com</td>
                  </tr>
                  <tr>
                    <td>Mary</td>
                    <td>Moe</td>
                    <td>mary@example.com</td>
                  </tr>
                  <tr>
                    <td>July</td>
                    <td>Dooley</td>
                    <td>july@example.com</td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>

关于html - 调整浏览器大小时 Bootstrap 表超出面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39779625/

相关文章:

html - 使用此规则 "element element"不应用 css。这段代码有什么问题?

html - 验证消息包装

html - Font Awesome 图标根本不显示

jquery - 选择框作为类别过滤器在 Chrome、IE 上不起作用。

html - CSS3 Ellipsis 削减以不同字符结尾的字符串

html - 显示 :inline 时鼠标单击未注册在多行文本的尾随空格中

html - Bootstrap 3 .img 响应图像不是链接内的响应图像

html - 在 2 个固定 block 之间创建一个 block

javascript - 根据字母添加类别

jquery - 在同一容器中的另一个 div 上显示 z 索引的 div