网页垂直居中例子

程序代码 程序代码

<!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>



[本日志由 journey 于 2009-12-03 04:02 PM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: 网页 垂直 居中 例子
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.