复制代码代码如下: <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. this is test. this is test. this is test. this is test. this is test. this is test. this is test.
复制代码代码如下: <style> body {padding:0; margin:0; } /*这些是专用FIREFOX写的,注意IE7也认识*/ html,body{ height:100%;} #infoBox[id]{text-align:center; width:100%; height:100%; display:table;} #info[id]{ display:table-cell; vertical-align:middle;} /*这里可以指个宽度试试,是可以自适应的*/ /*专为IE6写的*/ *html #infoBox{ position:absolute; top:50%; width:100%; text-align:center; display:block; height:auto} *html #info{position:relative; top:-50%; border:1px solid #333399; text-align:center;} /*这里可以指个宽度试试,是可以自适应的*/ /*这理是专用IE7写的,注意[id]要加上,不然优先JI没有最上边那段NB*/ *+html #infoBox[id]{ position:absolute; top:50%; width:100%; text-align:center; display:block; height:auto} *+html #info[id]{position:relative; top:-50%; border:1px solid #333399; text-align:center;} /*这里可以指个宽度试试,是可以自适应的*/ </style> <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.