0

Here is the table I have made : JSFiddle link

At first it was working well but I wanted to add the scroll on the left because table had a lot of rows. In order to do it I have set the overflow:auto to the tbody in the CSS. It didn't work. Then I added

#training_table thead, #training_table tbody {
    display:block;
}

After that it worked, there is a scrollbar however as you see on the link all the rows are compressed. Now I can't make them to look correctly. What was my mistake?

EDIT: the head of the table shouldn't go up when scrolling. (should be always visible)

3
  • can you fix your fiddle, see only 2 rows (pitchers and batters), and the text is white. Commented Jun 24, 2013 at 6:34
  • @badZoke I have just updated and edited the link, click to it once more please Commented Jun 24, 2013 at 6:34
  • added answer please check Commented Jun 24, 2013 at 6:49

2 Answers 2

1

Remove the display: block; from #training_table thead, #training_table tbody

And add these to #training_table,

height: 200px; // or whatever your limit is
display: table-cell;
overflow-y: scroll; //as per your preference 
overflow-x: hidden; //as per your preference

Test Link -- full screen

Test Link -- fiddle

Sign up to request clarification or add additional context in comments.

1 Comment

I see, but the table head goes up when scrolling too. I need it to stay always on top even if scrolling.
0

Just make the following change to the css and it will work fine:
Replace display: block; with display: block inline;

3 Comments

Then the overflow:auto is not making effect: no scrollbar appears.
i tried this in your fiddle and its working fine there. I just updated #training_table thead, #training_table tbody rule.
well i don't know why you cant see the scroll bar there. By the way i tested this in chrome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.