Apr 30

让你的网页内容上下左右都居中 不指定

Steven , 16:22 , 记录 , 评论(3) , 引用(0) , 阅读(1282) , Via 本站原创 | |
怎样让你的网页内容在不同尺寸和不同分辨率的显示器下显示都是上下左右居中的呢?或许下面这段代码能够帮到你,关键参数是#innerWrap里的设置。

如果不懂怎样操作就留言给我



<!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>
<style type="text/css">
<!--
body{margin:0;padding:0;background:#5a0026;font-family:"宋体",Arial,Tahoma;font-size:12px;text-align:center;}
/*全局设置*/
#wrap{margin:0 auto;padding:0 inherit;width:100%;overflow:hidden;background:#eee;}
#innerWrap{width:500px;height:300px;border:1px solid #999;background:#ccc;position:absolute;top:50%;left:50%;margin:-150px 0 0 -250px;line-height:300px;text-align:center;}
-->
</style>

</head>

<body>
<div id="wrap">
        <div id="innerWrap">这里是你的主体部分</div>
</div>
</body>
</html>
ZNZ Homepage
2009/08/10 22:16
受用了
一直没见你更新文章 这里难道要荒废了?
Steven 回复于 2009/08/13 15:45
呵呵,不会的,只是现在比较忙,更新的慢了
PengUIN Email Homepage
2009/05/25 04:55
我最近也在找这个
这个方法固定了层的大小,如果是长宽不定的层就不能用这个方法了。
罗西南尔
2009/05/19 11:05
学无止境 www.bj-pingan.com
分页: 1/1 第一页 1 最后页
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]