2013-03-02 60 views

回答

21

可用的一个选项是fooTable。在响应网站的伟大工程,并允许您设置多个断点... fooTable Link

+0

[FooTable现在可以与开箱即用的Twitter Bootstrap一起使用。](http://fooplugins.com/footable/demos/getting-started.htm#setup) – 2014-08-21 10:42:38

17

有很多不同的东西与响应表打交道时,你可以做。

我个人很喜欢这种方法由克里斯Coyier:

您可以在这里找到许多其他的替代品:

如果你可以利用引导并迅速得到的东西,你可以简单地使用类名“.hidden手机”和“.hidden片剂”隐藏某些行,但这种方法可能是最好的在许多情况下。更多信息(请参阅 “响应实用工具类”):

+5

Coyer Link的+1。我以前用过这个效果很好。 – 2013-10-15 09:57:16

+0

是的,Chris Coyer的解决方案非常整齐。比bootstrap或zurbfoundation提供的更好(它们只是添加水平滚动)。 – 2015-04-09 16:00:39

+0

截至目前,2016年1月,Coyier和其他人的响应材料是5 - 6岁,在每个人开始使用Twitter Bootstrap之前。 – 2016-01-31 19:30:04

150

Bootstrap 3现在有响应表开箱。万岁! :)

您可以点击此处查看:https://getbootstrap.com/docs/3.3/css/#tables-responsive

添加<div class="table-responsive">围绕你的表,你应该是好去:

<div class="table-responsive"> 
    <table class="table"> 
    ... 
    </table> 
</div> 

为了让你能做到这一切的布局工作:

.table-responsive 
{ 
    overflow-x: auto; 
} 
+7

但它只适用于小型设备(768px以下):S来源:http://getbootstrap.com/css/#tables-responsive – VSP 2013-12-09 15:16:07

+1

要在所有大小的布局上启用此功能,您只需从768阻止在foundation_and_overrides.css.scss文件中。类似于“''\t。表格响应{ \t宽度:100%; \t \t overflow-y:hidden; \t \t overflow-x:scroll; \t \t -ms-overflow-style:-ms-autohiding-scrollbar; \t \t -webkit-overflow-scrolling:touch; \t} ''' – genkilabs 2014-02-14 21:19:29

+3

@ ase69s检查我的更新答案。刚才我需要一张有很多列的桌子。在自定义的'CSS'文件中添加'overflow-x:auto'会为更大的显示布局带来诀窍。 – 2014-04-14 23:31:08

1

如果您正在使用引导3以上,你可以通过updatingthe文件应用的响应表中的所有决议案:

tables.less 

或覆盖该部分:

@media (max-width: @screen-xs) { 
    .table-responsive { 
    width: 100%; 
    margin-bottom: 15px; 
    overflow-y: hidden; 
    overflow-x: scroll; 
    border: 1px solid @table-border-color; 

    // Tighten up spacing and give a background color 
    > .table { 
     margin-bottom: 0; 
     background-color: #fff; 

     // Ensure the content doesn't wrap 
     > thead, 
     > tbody, 
     > tfoot { 
     > tr { 
      > th, 
      > td { 
      white-space: nowrap; 
      } 
     } 
     } 
    } 

    // Special overrides for the bordered tables 
    > .table-bordered { 
     border: 0; 

     // Nuke the appropriate borders so that the parent can handle them 
     > thead, 
     > tbody, 
     > tfoot { 
     > tr { 
      > th:first-child, 
      > td:first-child { 
      border-left: 0; 
      } 
      > th:last-child, 
      > td:last-child { 
      border-right: 0; 
      } 
     } 
     > tr:last-child { 
      > th, 
      > td { 
      border-bottom: 0; 
      } 
     } 
     } 
    } 
    } 
} 

有了:

@media (max-width: @screen-lg) { 
    .table-responsive { 
    width: 100%; 
... 

注意我是如何改变的第一行@屏幕-XX值。

我知道让所有表响应听起来不是那么好,但我发现它非常有用的这个中启动的LG大表(大量列)。

希望它可以帮助别人。