Jump to content
liverpool-phil

w3.css - tables and a scroll bar

Recommended Posts

HI I am trying to have a table with fixed header, and scrollable data cells below. on the right hand side of the table I would like a scroll bar to allow the data cells to scroll vertically.

This is the code I'm currently trying (without success)

.pb-scroll {
	display: 	 block;
	max-height:  400px;
	overflow:	 auto;
}

<tbody class="pb-scroll">
  <tr>
    <td>
      
      etc.

Any help greatly appreciated.

Phil

Share this post


Link to post
Share on other sites

Tables don't do that! Try using two tables, one for header, another for data content and use scrolling for a container element around  the second table.

Share this post


Link to post
Share on other sites

HI dsonesuk,

Thanks for the quick response.

So one table for the headers and another for the data - I guess I can use the two sets of tables column widths in sync using width: x%

I'll give it a try.

Thanks

Phil

 

Share this post


Link to post
Share on other sites

Have tried the suggested solution but it is pretty hard to keep things in alignment. The scroll bar adds to the last column which throws the edge out with the headers table.

Any suggestions on keeping things lined up?

 

Thanks

Phil

Share this post


Link to post
Share on other sites

https://www.w3schools.com/code/tryit.asp?filename=G6A3A9X7PEY4

 

The problem is different browsers, different scrollbar widths, I tried this in three main browsers IE,Chrome, FF, and they are identical, if you find browser that causes misalignment because of scrollbar I suggest you re-enable 

.table-header {/*overflow-y:scroll;*/}

This will created scrollbar in header, even not required but will Make ALL browsers correctly to column widths.  

Edited by dsonesuk

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...