Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4233864
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:16:30+00:00 2026-05-21T02:16:30+00:00

By generalizing the code in this SO answer , I’ve created a small jQuery

  • 0

By generalizing the code in this SO answer, I’ve created a small jQuery plug-in which makes it easy to set up a scrolling header on any table – that is, when you scroll down such that the table header would normally be outside of the viewable window, a clone of the header becomes fixed to the top of the window so that you can see which columns are which. That’s all working fine, but the problem I’m having is that I can’t get the column widths to match up perfectly between the clone table and the original table.

I’ve created a jsFiddle which demonstrates the problem here. The gist of it is that I’m using the following loop to copy cell widths from the parent table to the clone table:

$("#tbl1").find('tr').first().children().each(function(i, e)
{
    $($("#tbl1_clone").find('tr').children()[i]).width($(e).width());
});

This is necessary because the clone table only consists of the parent table’s header; it has none of the content, therefore its column widths would be different than the parent table’s without this step. However, this loop doesn’t quite work properly. The cell widths in the cloned table are always off by a few pixels. This happens in both IE8 and Chrome (and presumably others, though I haven’t tested them.)

I’m at a complete loss as to how to correct this problem. Please check out the jsFiddle, as it explains the problem much better than I have.

It’s perhaps worth noting that the same code seems to work when the clone table’s position is not fixed. However, that’s of no use to me, since I need it to be fixed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T02:16:31+00:00Added an answer on May 21, 2026 at 2:16 am

    For some reason, the width attribute on your cloned table is throwing off the calculations. I’m not exactly sure why but if you use:

    $("#tbl1_clone").removeAttr('style');
    

    at the end of your jquery code like, here, it seems to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some PHP code that should cause and catch two exceptions: try{ @$this->connector->connect();
Up until this point, I haven't done much in javascript. I recently started playing
I'm writing a program which will use scan conversion on triangles to fill in
I have several complex data structures like Map< A, Set< B > > Set<
I wrote the following code in Haskell to compute the dot product of two
I'm in the process of generalizing a Django DB replication app and it uses
I have a number of different projects, which are maturing to the level that
Below is an implementation of a function that returns the lexographically next permutation. This
I want to preface this by saying that this is a homework assignment. I
I have a function which takes in a list of characters and generates the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.