Solved

Table with scroll bars

Posted on 2014-01-01
4
351 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery Autocomplete PHP script 3 37
Understanding Trigger in Jquery 10 49
jQuery Animation faster 5 42
Form with Modals 16 42
Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…

912 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

20 Experts available now in Live!

Get 1:1 Help Now