Solved

Table with scroll bars

Posted on 2014-01-01
4
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
The viewer will learn how to dynamically set the form action using jQuery.
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)

734 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