<table align="center">
<tr>
<td align="center">
</td>
</table>
以上方法只能让整个table在页面中左右居中,而不能上下居中!怎样让整个table在页面中间呢?
7 个解决方案
#1
<body leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
#2
更正:
<body leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600 scroll=no>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
<body leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600 scroll=no>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
#3
<div align=center valign=middle>
<table>
<tr><td>Look This</td></tr>
</table>
</div>
<table>
<tr><td>Look This</td></tr>
</table>
</div>
#4
valign=middle
#5
同意 lbd8848(lbd)
#6
lbd8848(lbd)的方法有点局限性(限制死了800x600),可以试试下面的:
<html>
<body>
<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%>
<tr><td width=100% align=center valign=center>
<table border=1>
<tr><td>Your table goes here</td></tr>
</table>
<td></tr>
</table>
</body>
</html>
<html>
<body>
<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%>
<tr><td width=100% align=center valign=center>
<table border=1>
<tr><td>Your table goes here</td></tr>
</table>
<td></tr>
</table>
</body>
</html>
#7
呵呵~这才是真正的答案:
<table bgcolor="#jnkc" width="300" height="200" style="position:absolute;z-index:1;left:expression((document.body.clientWidth-this.offsetWidth)/2);top:expression((document.body.clientHeight-this.offsetHeight)/2)">
<tr>
<td> </td>
</tr>
</table>
<table bgcolor="#jnkc" width="300" height="200" style="position:absolute;z-index:1;left:expression((document.body.clientWidth-this.offsetWidth)/2);top:expression((document.body.clientHeight-this.offsetHeight)/2)">
<tr>
<td> </td>
</tr>
</table>
#1
<body leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
#2
更正:
<body leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600 scroll=no>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
<body leftmargin=0 topmargin=0>
<table border=0 cellpadding=0 cellspacing=0 width=800 height=600 scroll=no>
<tr><td align=center valign=center>
<table border=1 bgcolor=red>
<tr><td>hello</td></tr>
</table>
<td></tr>
</table>
</body>
#3
<div align=center valign=middle>
<table>
<tr><td>Look This</td></tr>
</table>
</div>
<table>
<tr><td>Look This</td></tr>
</table>
</div>
#4
valign=middle
#5
同意 lbd8848(lbd)
#6
lbd8848(lbd)的方法有点局限性(限制死了800x600),可以试试下面的:
<html>
<body>
<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%>
<tr><td width=100% align=center valign=center>
<table border=1>
<tr><td>Your table goes here</td></tr>
</table>
<td></tr>
</table>
</body>
</html>
<html>
<body>
<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%>
<tr><td width=100% align=center valign=center>
<table border=1>
<tr><td>Your table goes here</td></tr>
</table>
<td></tr>
</table>
</body>
</html>
#7
呵呵~这才是真正的答案:
<table bgcolor="#jnkc" width="300" height="200" style="position:absolute;z-index:1;left:expression((document.body.clientWidth-this.offsetWidth)/2);top:expression((document.body.clientHeight-this.offsetHeight)/2)">
<tr>
<td> </td>
</tr>
</table>
<table bgcolor="#jnkc" width="300" height="200" style="position:absolute;z-index:1;left:expression((document.body.clientWidth-this.offsetWidth)/2);top:expression((document.body.clientHeight-this.offsetHeight)/2)">
<tr>
<td> </td>
</tr>
</table>