【问题标题】:Twitter Bootstrap table with fixed header and first column together带有固定标题和第一列的 Twitter Bootstrap 表
【发布时间】:2016-01-20 12:21:39
【问题描述】:

我有下表,第一列是固定的。

JSFiddle:

https://jsfiddle.net/f7v2xaph/

<iframe width="100%" height="300" src="//jsfiddle.net/f7v2xaph/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

我想问一下,如何更新代码以获得固定的标题?

我试过这个解决方案

Scrollable table with fixed header in bootstrap

但是没有运气来处理固定的第一列。

非常感谢您的建议。

【问题讨论】:

  • 您是否尝试过这些 solutions given here 或以您现在的方式为第一个th,this fiddle 为所有@ 987654327@
  • 谢谢,但在您的小提琴中移动标题存在问题。
  • @redrom 什么问题??
  • 在小提琴中你链接了。如果您水平移动,则航向未正确更新。
  • 那是因为您所说的第一个小提琴的方式是先修复它,然后通过克隆元素来习惯它..

标签: jquery css twitter-bootstrap gridview


【解决方案1】:

如果可以在 CSS 中使用 Javascript,请避免使用:

.table-responsive thead {
   position: fixed;
}

另外,如果你不想让你的头遮住你的身体,你需要做一个小技巧:

.table-responsive {
    margin-top: 40px; // height of your thead tr
}

.table-responsive thead {
    position: fixed;
    top: 0;
}

修复thead 的第二个问题是thead 的单元格宽度与tbody 的单元格宽度不匹配...您必须使用width 属性修复它,每个单元格的单元格。

【讨论】:

  • 谢谢,但现在标题在垂直滚动期间固定(这没关系),但在水平滚动期间没有移动。您能否建议,如何解决它或更新我的小提琴?
  • 能否请您添加一些您的代码的工作示例?
猜你喜欢
  • 1970-01-01
  • 2011-04-30
  • 2014-09-08
  • 1970-01-01
  • 2014-02-22
  • 1970-01-01
  • 2012-09-04
  • 2018-01-13
  • 2012-07-14
相关资源
最近更新 更多