视图上http://www.eveo.org
下载站点,方便修改:
http://www.eveo.org/backup/eveo.rar
http://www.eveo.org/backup/eveo.zip水平和垂直居中网站
正如你可以看到,现在,它的水平和垂直使用一个简单的表法中心:
<table cellpadding="0" cellspacing="0">
<tr>
<td align="left">
*put anything in here and it will be aligned horizontally and vertically
</td>
</tr>
</table>
accompanying CSS:
table
{
height: 100%;
width: 100%;
vertical-align: middle;
}
但是,在我的文档中我没有设置文档类型,我只有:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
如果我添加一个标准的文档类型,如下列:
<!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" lang="en" xml:lang="en">
我的表的方法不再有效并不起作用。因此,无论浏览器窗口大小如何,我都需要一种新的方式来垂直和水平居中我的网页。
看到http://stackoverflow.com/questions/396145/whats-the-best-way-of-centering-a-div-vertically -with-css? – Mat