jquery - 带有固定标题和第一列的 Twitter Bootstrap 表

标签 jquery css twitter-bootstrap gridview

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

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

但是没有幸运地使用固定的第一列。

非常感谢您的任何建议。

最佳答案

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

.table-responsive thead {
   position: fixed;
}

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

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

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

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

关于jquery - 带有固定标题和第一列的 Twitter Bootstrap 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33260410/

相关文章:

angularjs - bootstrap 和 Ionic 的区别

Javascript/jQuery 字符串操作?

asp.net - 如何读取外部页面的标题?

php - 为什么 Slick slider 不能在表单标签内工作?

html - 设置 GitHub Pages 元素页面。页面打开但图像和 main.css 未加载

html - 在 IE 中将按钮标记为默认

jquery - 如何使用 jquery 读取列表框中所有项目的值

带图片和渐变的CSS背景,多行怎么写?

javascript - validator.js with bootstrap 你如何知道你的表单在 AJAX 表单上有效?

html - 类输入组在 Firefox 和 IE 中不显示占位符或接受输入