bootstrap表头表列固定后,列水平滚动表头不滚动的解决方法
$.extend($.fn.bootstrapTable.defaults, {
stickyHeader: false,
stickyHeaderOffsetY: 0,
fixedColumns: true, //固定列
fixedNumber: 4 //固定第3列
});
{ key: 'matchPositionX', value: function matchPositionX() {
var left = this.$tableBody.scrollLeft(); this.$stickyContainer.scrollLeft(left);
//是否有固定表列 if (this.options.fixedColumns === true) {
var fixedNumber = this.options.fixedNumber;
this.$stickyHeader.find('tr:eq(0)').find('th').each(function (index, el) {
$(el).css("background-color", "white");
$(el).css("position", "relative");
$(el).css("z-index", "100");
//大于设置的固定表列,设置滚动
if (index >= fixedNumber) {
$(el).css('transform', 'translateX(-' + left + 'px)');
$(el).css("z-index", "99"); } }); } } }