网络编程
位置:首页>> 网络编程>> 网页设计>> CSS解决未知高度的垂直水平居中自适应问题(3)

CSS解决未知高度的垂直水平居中自适应问题(3)

作者:zishu 来源:zishu博客 发布时间:2009-03-17 17:06:00 

标签:css,问题,自适应,垂直居中

三、DIV不知道高度怎么让他水平和垂直居中?

这个比较麻烦,用上边的方法的一半再加一些代码才能实现! 

首先我先按上边代码意思接着写,注意,下边的代码是我写好的第一步,只支持IE6和IE7,不过先看一下!

<style>
body {padding:0; margin:0; }
#infoBox{ position:absolute; top:50%; width:100%; text-align:center;}
#info{position:relative; top:-50%; right:0; border:1px solid #333399; text-align:center;} /*这里可以指个宽度试试,是可以自适应的*/
</style>
<div id="infoBox">
 <div id="info">
  this is test.<br />this is test.<br />this is test.<br />this is test.<br />this is test.<br />this is test.<br />this is test.<br />this is test.<br />
 </div>
</div>


那么,如果让Firefox再支持一下就可以,对吧!所以接着写!

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com