FARGORE Posted April 15, 2012 Report Share Posted April 15, 2012 Greetings What I want to do is have a table of data on a web page. The amount of data in the table can change but I want there to be a max height to the table so if the size of the table gets to long it will use scroll bars instead of actually making the table larger.So basically I want to make a table that has a MAX height but can present any amount of information. I tried to find a way of doing this with CSS and could not find a max height option. I found the Iframe HTML tag and that seems like it will do what I want but my question is, is that the best way or is there a better way? Thank you very much to anyone who takes time to answer my question. I hope everyone is having a good day. Link to comment Share on other sites More sharing options...
Err Posted April 15, 2012 Report Share Posted April 15, 2012 (edited) Make your table a fixed height: 300px height or whatever you want the max to be. Inside your table add a <div> with an overflow of auto and a height of the max size you want. If anything goes outside the 300px (in my example) then scroll bars will appear. What does the trick is the <div> and the overflow: auto;, overflow doesn't work quite right on <td> so you're better off using a div. <table style="height:300px;"> <tr> <td> <div style="overflow:auto; height:300px;">YOUR CONTENT HERE</div> </td> </tr></table> Edited April 15, 2012 by Err Link to comment Share on other sites More sharing options...
Ingolme Posted April 15, 2012 Report Share Posted April 15, 2012 You can put the table inside a <div> element of a fixed height and overflow set to "auto" Link to comment Share on other sites More sharing options...
FARGORE Posted April 15, 2012 Author Report Share Posted April 15, 2012 Thank you both very much for your responses. This is exactly what I was looking for. 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