Html Table Resize Height And Td Height - HTML & CSS - SitePoint
Có thể bạn quan tâm
Hi,
I have a html table and I am unable to change his height value to fit the browser window height though it was set to height: 100% in CSS;
so to change the size dynamically I have done something with javascript
- change the height of tbody, but doing this the height of each td has been stretched;
- I adjust the td height of each row within tbody;
So I want to obtain a higher tbody and td with normal height (15px), but there is something wrong in the code.
Here is my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title></title> <style type="text/css"> table tr td{ border: 1px solid red; } table tbody { background: #CCC; } </style> <script> function resize_tbody() { if (document.getElementById("my_table_tbody")) { document.getElementById("my_table_tbody").style.height = "350px"; var num_rows_tbody = document.getElementById("my_table_tbody").rows.length; for (a = 0; a <= num_rows_tbody - 1; a++) { document.getElementById("my_table_tbody").getElementsByTagName("td")[a].style.height = "15px"; } } } </script> </head> <body> <table> <caption>TABLE</caption> <thead> <tr> <th>col_1</th> <th>Col_2</th> </tr> </thead> <tbody id='my_table_tbody'> <tr> <td>1.1</td> <td>1.2</td> </tr> <tr> <td>2.1</td> <td>2.2</td> </tr> <tr> <td>3.1</td> <td>3.2</td> </tr> </tbody> <tfoot> <tr> <td>foot 1</td> <td>foot 2</td> </tr> </tfoot> </table> <script> resize_tbody(); </script> </body> </html>I hope I have explained well enough this issue. Can you help me please? Many thanks.
Từ khóa » Html Table Row Height Stretch
-
How To Fit HTML Table Row To Its Content - Stack Overflow
-
A Way To Stretch Only The BOTTOM Table Cell To Fill 100% Page Height?
-
Table Cell Auto Stretching When Height Is Defined - P2p .wrox .coM
-
CSS Table-layout Property - W3Schools
-
Table-layout - CSS: Cascading Style Sheets - MDN Web Docs
-
How To Fix The Height Of Rows In The Table? - GeeksforGeeks
-
Html - DIV Stretch To Height 100% In A Table Cell
-
Html Table Exceeding Height Code Example - Code Grepper
-
CSS- Div- Be Careful When You Size Your Divs
-
How To Make All Rows In Table Component Stretch To Be Of Same ...
-
Stretch Container In Table Cell To Full Height - AngularFix
-
Table Cell Auto Stretching Vertically When Defined Height - HTML / CSS
-
Video: Resize Table Rows And Columns - Microsoft Support
-
Table-layout - CSS-Tricks