Skip to content

Instantly share code, notes, and snippets.

@jmosbech
Created June 6, 2012 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmosbech/2884014 to your computer and use it in GitHub Desktop.
Save jmosbech/2884014 to your computer and use it in GitHub Desktop.
border-collapse.patch
js/jquery.stickytableheaders.js | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/js/jquery.stickytableheaders.js b/js/jquery.stickytableheaders.js
index 281af35..f4fd91e 100644
--- a/js/jquery.stickytableheaders.js
+++ b/js/jquery.stickytableheaders.js
@@ -87,16 +87,23 @@
};
base.updateCloneFromOriginal = function () {
+ var borderCompensation = 0;
+ $origTh = $('th', base.$originalHeader);
+
+ if( $origTh.css('border-collapse') == 'collapse' && $origTh.css('border-left-width') != '0px' ) {
+ borderCompensation = parseInt($origTh.css('border-left-width').replace('px', ''), 10);
+ }
+
// Copy cell widths and classes from original header
$('th', base.$clonedHeader).each(function (index) {
var $this = $(this);
var origCell = $('th', base.$originalHeader).eq(index);
$this.removeClass().addClass(origCell.attr('class'));
- $this.css('width', origCell.width());
+ $this.css('width', origCell.width() + borderCompensation);
});
// Copy row width from whole table
- base.$clonedHeader.css('width', base.$originalHeader.width());
+ base.$clonedHeader.css('width', base.$originalHeader.width() + borderCompensation);
};
// Run initializer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment