Solved

Table with scroll bars

Posted on 2014-01-01
4
349 Views
Last Modified: 2014-01-17
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
Comment
Question by:tonelm54
  • 3
4 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39750124
I think you need some css. I also made some minor modifications to the script.

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

Author Comment

by:tonelm54
ID: 39750203
I think CSS is the issue, however the code that you posted still has the columns are still going off :-(
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39750354
What browser/version are you using?
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 39750647
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now