如何将页脚固定在页面底部

方法一:

HTML:

<div id="container">
<div id="hearder">页头区域</div>
<div id="page" class="clearfix">页面内容</div>
<div id="footer">页脚</div>
</div>

CSS:

html,body{
margin:0;
padding:0;
height:100%;
}
#container{
min-height:100%;
height:auto !important;
height:100%;
position:relative;
}
#header{
background:#ff0;
padding:10px;
}
#page{
width:960px;
margin:0 auto;
padding-bottom:60px;/*等于footer高度*/
}
#footer{
position:absolute;
bottom:0;
width:100%;
height:60px;
background:#6cf;
clear:both;
}

方法二:

HTML:

<div id="container">
<div id="page">页面内容</div>
</div>
<div id="footer">页脚</div>

CSS:

html,body{
height:100%;
margin:0;
padding:0;
}
#container{
min-height:100%;
height:auto !important;
height:100%;
}
#page{
padding-bottom:60px;/*高度等于footer高度*/
}
#footer{
position:relatvie:
margin-top:-60px;
height:60px;
clear:both;
background:#c6f;
}

参考:Pure CSS:Sticky Footer

方法三:

HTML:

<div id="container">
<div id="page">页面内容</div>
<div class="push"></div>
</div>
<div id="footer">页脚</div>

CSS:

html,body{
height:100%;
margin:0;
padding:0;
}
#container{
min-height:100%;
height:auto !important;
height:100%;
margin:0 auto -60px;
}
.push,#footer{
height:60px;
clear:both;
}
#footer{
background:#f6c;
}

方法四:

HTML:

<div id="header">页头</div>
<div id="page" class="clearfix">页面内容</div>
<div id="footer">页脚</div>

CSS:

*{
margin:0;
padding:0;
}
.clearfix:before,.clearfix:after{
content:"";
display:table;
}
.clearfix:after{
clear:both;
}
.clearfix{
zoom:1;
}
#footer{
height:60px;
background:#fc6;
width:100%;
}
时间: 2024-08-13 05:59:37

如何将页脚固定在页面底部的相关文章

将HTML页面页脚固定在页面底部(多种方法实现)

当一个HTML页面中含有较少的内容时,Web页面的footer部分随着飘上来,处在页面的半腰中间,给视觉效果带来极大的影响,接下来为大家介绍下如何将页脚固定在页面底部,感兴趣的朋友可以了解下 作为一个Web的前端工作者学习者,在制作页面效果时肯定有碰到下面这种现象:当一个HTML页面中含有较少的内容时,Web页面的"footer"部分随着飘上来,处在页面的半腰中间,给视觉效果带来极大的影响,让你的页面看上去很不好看,特别是现在宽屏越来越多,这种现象更是常见. 那么如何将Web页面的&q

【转载自W3CPLUS】如何将页脚固定在页面底部

该文章转载自:W3CPLUS 大漠的文章 http://www.w3cplus.com/css/css-sticky-foot-at-bottom-of-the-page 以下为全文 作为一个Web的前端攻城师,在制作页面效果时肯定有碰到下面这种现象:当一个HTML页面中含有较少的内容时,Web页面的“footer”部分随着飘上来,处在页面的半腰中间,给视觉效果带来极大的影响,让你的页面看上去很不好看,特别是现在宽屏越来越多,这种现象更是常见.那么如何将Web页面的“footer”部分永远固定在

如何将页脚固定在页面底部?

作 为一个Web的前端攻城师,在制作页面效果时肯定有碰到下面这种现象:当一个HTML页面中含有较少的内容时,Web页面的“footer”部分随着飘上 来,处在页面的半腰中间,给视觉效果带来极大的影响,让你的页面看上去很不好看,特别是现在宽屏越来越多,这种现象更是常见.那么如何将Web页面的 “footer”部分永远固定在页面的底部呢?注意了这里所说的是页脚footer永远固定在页面的底部,而不是永远固定在显示器屏幕的底部,换句话说,就是当内容只有一点点时,Web页面显示在浏览器底部,当内容高度超

将HTML的页脚固定在屏幕下方

/********************************************************************* * 将HTML的页脚固定在屏幕下方 * 说明: * 处理的方法好像是比较多的,个人还是比较倾向于用JS进行处理. * * 2017-8-25 深圳 龙华樟坑村 曾剑锋 ********************************************************************/ 一.参考文档: 1. 将footer固定在页面底部

CSS中position属性的理解,相对位置relative,绝对位置absolute,固定fixed,页脚固定的实现2种方法

页脚固定的底部的两种方式: 1.使用fixed属性值 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title></title> 5 </head> 6 <body> 7 <div style="height: 1500px;width: 100%;background-color: green;margin-bottom: 320px;"> 8 9 <

让footer固定在页面底部

最近做了几个触屏版页面,页面比较简单,内容短,但是都有个底部,面对各种机型,底部不是一直处于底部位置,长屏.高分辨率的机子上的表现是悬在半空中,就像一根刺卡在喉咙啊.为此做了几种尝试. 其中有个活动的触屏页面只有一个,并且页面上内容固定,所以首先想到的处理方式也比较简单,也很实用. html代码: <header>头部</header> <div>内容</div> <footer>底部</footer> html代码方面不需要额外增加

Footer固定在页面底部(CSS)

<style type="text/css"> #wapper{ position: relative; /*重要!保证footer是相对于wapper位置绝对*/ height: auto; min-height: 100%; } #main-content{ background:grey; padding-bottom: 60px; /*重要!给footer预留的空间*/ } #footer{ background: green; width: 100%; posit

Web开发用到的导航栏固定顶端,页脚固定低端

直接上代码 <!DOCTYPE html> <html lang="zh"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta charset="utf-8" /> <title>About - 我的 ASP.NET MVC 应用程序<

footer固定在页面底部的若干种方法

1 <div class="header"><div class="main"></div></div> 2 <div class="container"><div class="main"></div></div> 3 <div class="footer"><div class="