DIV+CSS 制作上下左右都居中的div图层的一种方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="gb2312" >
<head>
<title>上下左右都居中的div图层 css</title>
</head>

<style type="text/css" title="currentStyle" media="screen">
#center{
   position:absolute;
   top:50%;
   left:50%;
   margin-top:-200px;
   margin-left:-300px;
   width:600px;
   height:400px;
   border:1px solid #333333;
}
</style>
</head>
<body>
<div id="center">
</div>
</body>
</html>

==========================

   margin-top:-200px;
   margin-left:-300px;
   width:600px;
   height:400px;

请注意以上标注参数的倍数关系!

Trackbacks: 点击获得Trackback地址,Encode: UTF-8  点击获得Trackback地址,Encode: GB2312 or GBK  点击获得Trackback地址,Encode: BIG5
Tags: div | 分类:CSS & JS
浏览概况:评论:2 | 相关文章:2 | 阅读:17408
相关文章
文章评论(2)
[1楼] [引用] [TOP]
小戴 发表于 2008, December 11, 10:08 AM
好象这个方法比较死。如果是宽平了,
[2楼] [引用] [TOP]
Copterfly 发表于 2008, December 11, 8:36 PM
再宽的屏也没关系,因为重点在这两句:
top:50%;
left:50%;
发表评论
用户名:
密码(游客无需):
网址/E-mail:
      记住我的信息