2013-06-30 27 views
2

問題:使用reset.css時,我不知道如何更改頁腳的高度,頁腳div的高度屬性不會改變任何內容。更改頁腳css的高度

您可以在本地複製這一點,check it out here

HTML

<div class="wrapper"> 
    <p>Your website content here.</p> 
</div> 
<div id="footer"> 
    <p>&copy; 2013 Friend | Design and Development. All Rights Reserved.</p> 
</div> 

CSS - style.css中

html, body { 
    height: 100%; 
    font-family: 'Arial', Helvetica; 
} 

.wrapper { 
    min-height: 100%; 
    height: auto !important; 
    height: 100%; 
    margin: 0 auto -4em; 
} 

#footer { 
    background: #444444; 
    height: 100px; 
    font-family: 'Open Sans', sans-serif; 
    color: #FFFFFF; 
    padding: 20px; 
} 

RESET.css

/* http://meyerweb.com/eric/tools/css/reset/ 
    v2.0 | 20110126 
    License: none (public domain) 
*/ 

html, body, div, span, applet, object, iframe, 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
a, abbr, acronym, address, big, cite, code, 
del, dfn, em, img, ins, kbd, q, s, samp, 
small, strike, strong, sub, sup, tt, var, 
b, u, i, center, 
dl, dt, dd, ol, ul, li, 
fieldset, form, label, legend, 
table, caption, tbody, tfoot, thead, tr, th, td, 
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary, 
time, mark, audio, video { 
    margin: 0; 
    padding: 0; 
    border: 0; 
    font-size: 100%; 
    font: inherit; 
    vertical-align: baseline; 
} 

/* HTML5 display-role reset for older browsers */ 
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section { 
    display: block; 
} 
body { 
    line-height: 1; 
} 
ol, ul { 
    list-style: none; 
} 
blockquote, q { 
    quotes: none; 
} 
blockquote:before, blockquote:after, 
q:before, q:after { 
    content: ''; 
    content: none; 
} 
table { 
    border-collapse: collapse; 
    border-spacing: 0; 
} 

回答

1

如果將.wrapper上的負底邊距與頁腳高度相匹配,則應顯示整個頁腳。

或者,如果你要爲漂浮在底部或頁面頁腳,你可以這樣做:

<div class="wrapper"> 
    <div class="content"> 
     <p>Your website content here.</p> 
    </div> 
    <div id="footer"> 
     <p>&copy; 2013 Friend | Design and Development. All Rights Reserved.</p> 
    </div> 
</div> 

,並在CSS

.wrapper { 
    min-height: 100%; 
    position: relative; 
} 

.content { 
    /* padding the footer adds 40 to footer height */ 
    padding-bottom: 140px; 
} 

#footer { 
    position: absolute; 
    bottom: 0; 
    background: #444444; 
    height: 100px; 
    font-family: 'Open Sans', sans-serif; 
    color: #FFFFFF; 
    padding: 20px; 
} 

匹配高度。內容填充

(未經測試,如果需要,我會撥弄它)

+0

非常感謝。 – eveo

0
+0

這仍然不能解決問題。當我固定索引時更改高度仍然沒有任何作用。 – eveo

+0

嘗試在鏈接中更改它。 http://i.imgur.com/MIafB5k.png –

+0

只要注意到它不會出現在Firefox中。但是,這只是這樣,因爲它不允許垂直滾動。如果刪除.wrapper上的最小高度,則會發現高度更改正確。 –

0

d在Chrome中27,上.wrapper底邊距是限制#footer的可見高度。當height屬性增加時,頁腳會變得更高,但額外的高度(在.wrapper的4em之外)隱藏在初始視口高度之外。

所以,它完全按照指定執行:.wrapper佔用了除視口底部4em以外的所有區域,而#footer擁有與4em無關的高度。