网页垂直居中例子
作者:journey 日期:2009-05-29
程序代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网页垂直居中例子</title>
</head>
<body>
<table width="400" border="1" id="mainDiv" style="margin-top:0px;" align="center">
<tr>
<th colspan="2" scope="col">欢迎访问</th>
</tr>
<tr>
<th scope="row">网址</th>
<td><a href="http://www.itweb2.com" target="_blank">http://www.itweb2.com</a></td>
</tr>
</table>
<script type="text/javascript">
function OnResize()
{
document.getElementById("mainDiv").style.marginTop = (document.documentElement.clientHeight - 100) / 2 + " px";
}
OnResize();
window.onresize = OnResize;
</script>
</body>
</html>
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

文章来自:
Tags: