2012-11-06 23 views
-3

http://pastebin.com/GQ6Q0dti如何居中我的網頁

- 我想居中我的網頁,但我沒有找到成功的教程。 有人可以幫我解決我的問題 我只想把我的頁面居中。由於

+0

請代碼添加到您的問題。 SO以外的代碼片段傾向於被刪除,使得您的問題和答案對其他人無用。 – Sgoettschkes

+0

添加您的html代碼請 –

回答

1

如果你想水平居中+垂直使用position: absolute;

Demo

.center { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    height: 200px; 
    width: 400px; 
    margin-top: -100px; /* Half of container height */ 
    margin-left: -200px; /* Half of container width */ 
} 

,如果要居中它只水平簡單地使用這個

margin: 0 auto; 
     ^^
     T/B L/R 

就是不」噸忘記容器的寬度;)

+0

現在我的網頁是更多的左邊,並有一個巨大的差距右邊 –

+0

@ user1804060你正在使用所有明確的絕對定位.. –

0

,如果你要只水平中心,最好的辦法是不使用absolute位置,使用默認的位置和設置margin:0px auto;

#Table_01 { 
    width:792px; 
    margin:0px auto; 
} 
#template { 
    height:1584px; 
}