复制代码
代码如下:
<!DOCTY PE ht ML P ub LIC "-//W3C//DTD XHTML 1.0 Trans IT ional//EN" "http://www.w3. org /TR/xhtml1/DTD/xhtml1 -t ransitional.dtd">
<html XM lns="http://www.w3.org/1999/xhtml">
<head>
< ;m eta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>已知 宽 高度DIV垂直水平居</title>
<style type="text/css">
<!--
.m ai n{ position:absolute; top:50%; left:50%; width:821px; h ei ght:392px; m arg in:-196px 0 0 -410.5px; background: # C8E DF B}
-->
</style>
</head>
<body>
<div class="main">已知宽高度DIV垂直水平居</div>
</div>
</body>
</html>
说明:
width:821px; height:392px
mar gin 的取值为高和宽的一 半
总结
以上是 为你收集整理的 根据已知高和宽绝对垂直居中div示例代码 全部内容,希望文章能够帮你解决 根据已知高和宽绝对垂直居中div示例代码 所遇到的问题。
如果觉得 网站内容还不错, 推荐好友。
查看更多关于根据已知高和宽绝对垂直居中div示例代码的详细内容...