I have a floating HTML table header
, which remains at the top when the table is being scrolled through. I have implemented in by cloning the header of the original table and then hiding / showing it based on the scroll position.
When my table had a few columns, the "floating-header" had the same column width as the columns in the original table, due to this code:
$headerClone.children().outerWidth(function(i,val){
return $headerGrandChildren.eq(i).outerWidth(true);
});
However, now that the table has more columns and goes over the page right margin, the "floating-header" width is being adjusted and squeezed, disregarding the set width=x
style element and the table-layout: fixed;
CSS, see screenshot:
I have read that "The browser will then set column widths based on the width of cells in the first row of the table"
in here.
Question: how to best set the fixed size of the "floating-header"? Should I create an invisible row that would accompany the "fixed-header" so it would not resize as soon as my table is wider than the page?