2012-04-25 152 views
4

廣場頁腳總是我有以下頁面佈局:CSS:在底部

<header></header> 
<div id="content"></div> 
<aside></aside> 
<footer> 
<ul> 
    <li></li> 
</ul> 
</footer> 

現在我想以精確地放置頁腳在左上角:

text-align: left; 
position: fixed; 
bottom: 0; 
margin: -16px -8px; 

現在是負的邊緣不最好的解決方案。 有沒有更好的方法直接在角落定位頁腳?

問候

+0

是什麼瀏覽器您使用? http://jsfiddle.net/wyrju/在chrome上剪切測試文本。沒有負邊距就沒問題了。 – 2012-04-25 13:19:01

+0

映射時出現了錯誤(頁腳和頁腳之間的頁邊距ul) – bodokaiser 2012-04-25 13:48:31

回答

16

這樣寫:

text-align: left; 
position: fixed; 
bottom: 0; 
left:0 
+0

嗨,謝謝你的幫助。不幸的是,我有另一個問題: 當我設置寬度和填充頁腳,比li不在一行,但在彼此之下。如果我設置寬度和填充頁腳ul很好.. – bodokaiser 2012-04-25 13:50:41

+0

你可以推一些代碼以便更好地理解 – sandeep 2012-04-25 13:53:46

+0

嗨,已經解決了。忘記修復子元素的邊距/填充:) – bodokaiser 2012-04-25 13:55:09

7

檢查本網站Sticky Footer

例子:

* { 
    margin: 0; 
} 
html, body { 
    height: 100%; 
} 
.wrapper { 
    min-height: 100%; 
    height: auto !important; 
    height: 100%; 
    margin: 0 auto -142px; /* the bottom margin is the negative value of the footer's height */ 
} 
.footer, .push { 
    height: 142px; /* .push must be the same height as .footer */ 
} 
1

對我來說是這樣的:

height: 58px; 
position:relative; 
bottom: -58px; 

注意heightbottom的值相同。而postionrelative

0

HTML:

<div id="footer"></div> 

CSS:

#footer { 
    position:absolute; 
    bottom:0; 
    width:100%; 
    height:60px; /* Height of the footer */ 
    background:#6cf; 
}