So, learning how to set the table cell size is a very important part for every web designer. This tutorial will tell you how to fix it. But what would happen if the content is really too much? Don't worry, the tutorial will also tell you how to make a scrollable cell to ensure all the content in the cell are accessible.
It's always easier to learn with a working example. To make it work, you have to use CSS to help you. Take the following as an example
1: 2: 3: 4: 5: |
<style>
tr.entry{font-family: Verdana;font-size: xx-small;text-align:left; }
div.scrollablecell {overflow:auto;border:0px;word-wrap: break-word;width:100%;height:110px}
</style> |
You just need to focus on the styles of div.scrollablecell. Yes, it's a div, you will have each cell a div and your cell content will be stored in each of them. Within all the styles in the class scrollablecell, here's some simple description
overflow:auto - Shows scroll bar automatically if all content cannot be displayed.
word-wrap: break-word - Break a line to the next row if it's too long. If you also want to have a horizontal scroll bar, exclude this in the style.
***This is the CSS Level 3 standard and by the time only IE support it. If you are using Firefox, try to install Toggle Word Wrap add-on(https://addons.mozi
width, height - The size of the div. These must be set or the whole thing would not work. Better set them in unit of px(pixel) if you have not defined them in the cell.
These setting can bring you the result: if the content of the div cannot be shown within the block with height of 110px, then a scrollbar will appear and contents can be accessed by scrolling it.
So you got the styles and here's the corresponding html code of the table.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: | <table style="width: 200px;border:solid 1px #6699CC;table-layout:fixed;" cellspacing="0" cellpadding="0"> <tr style="background: #6699CC;height: 17%;width: 100%;"> <th style="text-align:center;"> <b><font size="2" face="Verdana" color="white">Content</font></b> </th> </tr> <tr class="entry" valign="top"> <td > <div class="scrollablecell"> your content here </div> </td> </tr> </table> |