Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

Table with scroll bars

I've been playing around trying to get a jQuery function to work, and it seems to work OK, however I'm having massive difficulty trying to get the columns to match up.

JSFiddle

I've set the columns to a fixed width, but they still seem to not line up.

Can someone please have a look and tell me where Im going wrong with the line up please?

Thank you
0
tonelm54
Asked:
tonelm54
  • 3
1 Solution
 
Tom BeckCommented:
I think you need some css. I also made some minor modifications to the script.

http://jsfiddle.net/x6tTR/2/
0
 
tonelm54Author Commented:
I think CSS is the issue, however the code that you posted still has the columns are still going off :-(
0
 
Tom BeckCommented:
What browser/version are you using?
0
 
Tom BeckCommented:
I would like to suggest a different approach.

What you have created will be problematic because you cannot predict how much width to allow for the scroll bar. Even if you get it right for one browser, it will be a little off for another. Table columns will line up differently with the header columns from one browser to the next.

What I suggest is to create two complete copies of the original table. Set the height of the first copy's div wrapper (which becomes the header row) to the height of one row. Set overflow to hidden to hide all other rows. Place it at the top of a parent div that I'll call #wrapper. Wrapper has a fixed height (I set it to 125px).

For the second table copy, set the height of it's parent div (I set it to100px), set overflow to scroll, remove the first row, and place the whole thing below the header row inside the same parent #wrapper.

I'm using jQuery methods that make the coding much more compact. I hope that's not too forward of me. I know how it is when you are trying to learn and someone throws a lot of new  techniques at you all at once.

I'm not in a position to test this in any browser on a Windows machine but it works well in Firefox and Chrome on a Mac.

http://jsfiddle.net/x6tTR/10/
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now