<!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>www.jb51.net</title>
<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>
</head>
<body>
<div id="infoBox">
<div id="info">
this is test.
this is test.
this is test.
this is test.
this is test.
this is test.
this is test.
this is test.
</div>
</div>
</body>
</html>
CSS自适应高度的div垂直水平居中
最新推荐文章于 2023-07-02 13:07:55 发布