จากที่เคยเขียน ให้ฟุตเตอร์อยู่ด้านล่างพอดีหน้าจอ
ถ้าหน้าเว็บสั้นกว่าจอโดยใช้ tableless เรามาย้อนยุคโดยใช้ตารางดูบ้าง
note
- ใช้ได้กับทุกบราวเซอร์รวมทั้งไอโฟนด้วย แต่ ie ต้องใช้ DOCTYPE เท่านั้น ถ้าเป็นตัวอื่นจะกำหนดความสูงของแถวไม่ได้
- ถ้าเนื้อหาน้อยมากๆ ตารางจะพยามชดเชยความสูงของตัวมันเองที่มากกว่าปกติ โดยจะเพิ่มความสูงของ tr ทดแทน ถ้าไม่อยากให้หน้าเว็บดูผิดปกติให้แก้
ที่มีปัญหาเป็น
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> < html > < head > < title >100% table height</ title > < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" > < link rel = "stylesheet" type = "text/css" href = "css3.css" > < style > html { height:100%; } body { height:100%; margin: 0px; padding: 0px; font-family: Helvetica, Arial, "Trebuchet MS", sans-serif; } table { border: 0 none; height:100%; } td { margin: 0px; padding: 0px; vertical-align:top; height:0px; } #header { background:#c00000; height:20px; } #footer { background:#c00000; height:20px; } </ style > </ head > < body > < table border = "1" class = "tablewrapper" > < tr > < td id = "header" >header</ td > </ tr > < tr > < td >contents</ td > </ tr > < tr > < td id = "footer" >footer</ td > </ tr > </ table > </ body > </ html > |
อ่านเพิ่มเติม
About the author