水平和垂直地定位网站 [英] Centering a website horizontally and vertically

查看:212
本文介绍了水平和垂直地定位网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.eveo.org 上查看

下载网站修改:

http://www.eveo.org/backup/eveo。 rar

http://www.eveo.org/backup /eveo.zip

正如您现在所看到的,它使用一个简单的表格方法水平和垂直居中:

As you can see right now, it is centered horizontally and vertically using an easy table method:

<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;
}


$ b <

However, in my document I did not set a doctype, I only have:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  

如果我添加标准的doctype,如下所示:

If I add a standard doctype such as the following:

<!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">

我的表方法不再有效,不起作用。因此,无论浏览器窗口大小如何,我都需要一种新的方式将网页垂直和水平居中。

my table method is no longer valid and does not work. So I need a new way to center my webpage vertically and horizontally regardless of browser window size.

推荐答案

一个很好的例子是这里

查看一个。

对于某些学习,请检查这个优秀的范例的gtalbot关于在CSS中的水平对齐。

For some learning, check this excellent example of gtalbot about horizonal align in CSS.

good luck>)

good luck >)

这篇关于水平和垂直地定位网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆