css实现的弹出窗口始终垂直水平居中成效

css实现的弹出窗口始终垂直水平居中效果

css实现的弹出窗口始终垂直水平居中效果:
本章节介绍一下如何实现一个弹出窗口实现垂直水平居中效果,无论是否拖动滚动条。
代码实例:

<!DOCTYPE html><html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style type="text/css">
body{
  height:1000px;
}
.antzoen{
  position:fixed;
  width:250px;
  height:100px;
  background:#ececec;
  left:50%;
  top:50%;
  margin-left:-125px;
  margin-top:-50px
}
</style>
</head>
<body>
<div class="antzoen"></div>
</body>
</html>

上面的代码实现了我们的要求,可以实现始终垂直水平居中的效果。
fixed在IE6中不支持,但是现在还用考虑IE6吗。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=15473

更多内容可以参阅:http://www.softwhy.com/divcss/