问题:我不知道如何在使用时更改页脚的高度reset.css,页脚 div 的高度属性不会改变任何内容。
您可以在本地克隆它并在此处查看
超文本标记语言
<div class="wrapper">
<p>Your website content here.</p>
</div>
<div id="footer">
<p>© 2013 Friend | Design and Development. All Rights Reserved.</p>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS - 样式.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;
}
Run Code Online (Sandbox Code Playgroud)
重置.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;
}
Run Code Online (Sandbox Code Playgroud)
如果将负底部边距与.wrapper页脚的高度相匹配,则应显示整个页脚。
或者,如果您想要浮动在页面底部的页脚,您可以这样做:
.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;
}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="content">
<p>Your website content here.</p>
</div>
<div id="footer">
<p>© 2013 Friend | Design and Development. All Rights Reserved.</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
将高度与.content填充匹配