【问题标题】:html bootstrap table not responsive with unordered list insidehtml引导表不响应内部无序列表
【发布时间】:2017-06-23 22:59:27
【问题描述】:

当我在小屏幕 320x568 中运行此代码时,表格内容会溢出包含它的整个 div。有什么办法可以解决这个问题。我希望他压缩或收缩一点只是为了适合容器。谢谢

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row ">
  <table class="table table-bordered table-sm table-responsive">
    <tbody>
      <tr>
        <td style="padding:20px">
          <p><strong>PART A - Reading Material </strong></p>
          <ul style="list-style-type:roman">
            <li><span class="blueprint">Self-help books</span></li>
            <li><span class="blueprint">Annotation sources</span></li>
            <li>Academic references
              <ul>
                <li><span class="blueprint">printed</span></li>
                <li><span class="blueprint">online</span></li>
              </ul>
            </li>
            <li><span class="blueprint">Editions of Batman</span></li>
          </ul>
        </td>
        <td style="padding:20px">
          <p><strong>Part B – Audio & Visual Material</strong></p>
          <ul start="5" style="list-style-type:roman; ">
            <li><span class="blueprint">Lectures on DVD</span></li>
            <li><span class="blueprint">YouTube original content</span></li>
            <li><span class="blueprint">Films & TV productions</span></li>
            <li><span class="blueprint">Audio recordings</span></li>
          </ul>
          <br>
          <br>
        </td>
        <td style="padding:20px">
          <p><strong>PART C – Material by Level</strong></p>
          <ul start="9" style="list-style-type:roman; ">
            <li><span class="blueprint">Introduction</span></li>
            <li><span class="blueprint">Variety of Materials</span></li>
          </ul>
        </td>
      </tr>
    </tbody>
  </table>
</div>

【问题讨论】:

  • css基于这个div,table在哪里??
  • 表格不应该真正用于内容,因为它对 SEO 不利。它们应该只用于数据集。表格也不是很敏感。我建议使用网格并将它们堆叠在移动设备上。
  • 唯一的其他解决方案是减少tds 上的填充并大大减小小屏幕的字体大小,但这会使内容难以阅读。

标签: jquery html css twitter-bootstrap


【解决方案1】:

考虑到目前还没有 css 可供使用,这有点困难。尝试为您的 div 使用百分比。然后,当它们缩小到太小的尺寸时,使用@media 查询来定义您想要停止浮动的宽度 - 添加 float:none 或 auto。此外,对于像您的徽标之类的图像,请确保包含 img {max-width:100%;} - 这将使它们能够很好地缩放。

@media (min-width: 1100px) {
  body {
    width:50%;
  }
}
@media (max-width: 1100px) {
  div {
    width:40%;
  }
}
@media (max-width: 480px) {
  div {
    width:20%;
  }
}

编辑:在移动设备中,您需要堆叠桌子,而使用桌子则无法做到这一点。谢谢@WizardCoder

【讨论】:

  • 我认为主要问题是他们使用表格来布局他们的内容。
  • 这是真的@WizardCoder,但如果我没记错的话,您可以将媒体大小调整为 元素
  • 你是对的,但我认为在这种情况下,他们应该在移动设备上堆叠列,而这是你不能用表格做的,
猜你喜欢
相关资源
最近更新 更多
热门标签