liverpool-phil Posted July 23, 2019 Share Posted July 23, 2019 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 Link to comment Share on other sites More sharing options...
dsonesuk Posted July 23, 2019 Share Posted July 23, 2019 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. Link to comment Share on other sites More sharing options...
liverpool-phil Posted July 23, 2019 Author Share Posted July 23, 2019 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 Link to comment Share on other sites More sharing options...
liverpool-phil Posted July 23, 2019 Author Share Posted July 23, 2019 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 Link to comment Share on other sites More sharing options...
dsonesuk Posted July 23, 2019 Share Posted July 23, 2019 (edited) 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 July 23, 2019 by dsonesuk Link to comment Share on other sites More sharing options...
liverpool-phil Posted July 23, 2019 Author Share Posted July 23, 2019 Thanks again dsonesuk, this will work or what I want. I also learned several new things 😊 I hadn't use colgroup before, and I didn't know you could do {width:calc(100%-8px);} Phil Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now