0

I have some troubles when creating scrollable table in HTML.

From some similar question in Stackoverflow, using overflow: auto in CSS is workable, but I can't implement successfully

Is there anyone who can help to check is there anything wrong in my code?

I'd like to make left red cell scrollable only.

#samples {
    overflow: auto;
    height: 200px;
}

Full code is in: Jsfiddle

Jimmy Lin
  • 1,481
  • 6
  • 27
  • 44

2 Answers2

2

Add the following CSS to the <table id="samples">

style="height:200px; overflow:auto;display:block;"

Or in the CSS file

#samples {
   overflow: auto;
   height: 200px;
   display:block;
}

Fiddle here


EDIT

This may not be what you want to hear, but display: table-cell does not respect width and will be collapsed based on the width of the entire table. You can get around this easily just by having a display: block element inside of the table cell itself whose width you specify

I've messed a little with the CSS in order to center the elements.

Fiddle

Filip Huysmans
  • 1,301
  • 1
  • 20
  • 44
0

one solution would be to put the table inside a div and make the div scrollable?

See this post -

Making a div vertically scrollable using CSS

Hope this helps.

Community
  • 1
  • 1
Dave
  • 76
  • 1
  • 8