2014-03-26 40 views
0

我試着將頁腳居中,但頁腳div會直接進入左側。 我的頁面結構是:如何居中底部固定格?

<body> 

    <div class="main_logo"> 
    </div> 

    <div class="main_menu"> 
    </div> 

    <div class="sub_menu"> 
    </div> 

    <div class="main_content"> 
    </div> 

    <div class="sys_breadcrumb"> 
    </div> 

    <div class="sys_footer" > 
    </div> 

</body> 

和頁腳CSS是

height:50px; 
width:1184px; 
margin:-25px 368px 0 368px; 
display:block; 

和我說

position: fixed; 
bottom:0; 
+0

你的 「答案」 已被刪除,因爲它沒有回答這個問題。這與此無關,所以我刪除了該部分。 – Doorknob

+0

上面的CSS應用於哪個元素? – Ani

+0

如果您已將其放置在頁面底部,則不需要任何額外的保證金。 –

回答

1

如果它的固定位置,你(可能)不需要(或想要)利潤率。刪除保證金聲明並添加:

left: 50%; 
margin-left: -592px; 

請注意592是頁腳寬度的一半(1184)。

+0

http://fiddle.jshell.net/kQeEL/5/ + http://fiddle.jshell.net/kQeEL/5/show/ – JohanVdR

+0

如果我加左:50%基本上它會佔用整個div在右側,離開頁面中間的div的左邊...... – 10000000

+0

這就是左邊的負邊距,用於接近 – jlblatt

0

刪除您的保證金 - 和你去:http://jsfiddle.net/96wMW/

.sys_footer { 
    height:50px; 
    width:1184px; 
    display:block; 
    background-color: red; 
    position: fixed; 
    bottom:0; 
} 
0

這裏:http://jsfiddle.net/vHNyb/5/

.sys_footer { 
background-color: red; 
position:fixed; 
bottom:0; 
width:100%; 
height:50px; 
width:1184px; 
margin:0; 
display:block; 
}