css讓頁腳始終在底部不論頁面內(nèi)容多少
發(fā)布時間:2013-09-06 10:22:24 作者:佚名
我要評論

讓頁腳始終在頁面底部,不論頁面內(nèi)容是多或者少頁腳始終在頁面底部,在某些情況下這些功能還是比較實用的,下面為大家介紹下幾種不錯的實現(xiàn)方法,大家可以參考下
讓頁腳始終在頁面底部,不論頁面內(nèi)容是多或者少頁腳始終在頁面底部。
方案一:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
body,html {
margin: 0;
padding: 0;
height:100%;
}
#main {
position: relative;
min-height:100%;
background:#eee;
}
#content {
padding: 10px;
padding-bottom: 100px;
}
#footer {
position: absolute;
bottom: 0;
height: 100px;
width: 100%;
background:lightblue;
}
</style>
</head>
<body>
<div id="main">
<div id="content">
<script type="text/javascript">
for(var i=0; i<400; i++){
document.write(i+'<br/>');
}
</script>
</div>
<div id="footer">
Footer
</div>
</div>
</body>
</html>
方案二:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>css實現(xiàn)頁腳始終在最底部</title>
<style type="text/css">
* {padding: 0;margin: 0;}
html {*overflow: auto;}
body {_width: expression(this.parentNode.clientWidth);}
html,body {height: 100%;}
.section {min-height: 100%;_height: 100%;}
.footer {height: 60px;background: #000;margin-top: -60px;color: #FFF;}
</style>
</head>
<body>
<div class="section">
<script type="text/javascript">
for(var i=0; i<400; i++){
document.write(i+'<br/>');
}
</script>
</div>
<div class="footer">我是頁腳</div>
</body>
</html>
讓頁腳始終固定在屏幕底部:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title></title>
<meta name="generator" content="editplus">
<meta name="author" content="Ariex">
<meta name="keywords" content="">
<meta name="description" content="">
<style type="text/css">
body{margin:0px;padding:0px;overflow:hidden;padding-top:22px;padding-bottom:22px;}
#header{background-color:blue;color:white;position:absolute;top:0px;left:0px;height:16px;width:100%;}
#content{background-color:yellow;width:100%;height:100%;overflow:auto}
#footer{background-color:green;color:white;width:100%;height:16px;position:absolute;bottom:0px;left:0px;}
</style>
<script language="javascript">
</script>
</head>
<body>
<div id="header">header</div>
<div id="content">
<script language="javascript">
for(i=0;i<1000;i++){
document.write(i+"
");
}
</script>
</div>
<div id="footer">footer</div>
</body>
</html>
方案一:
復(fù)制代碼
代碼如下:<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
body,html {
margin: 0;
padding: 0;
height:100%;
}
#main {
position: relative;
min-height:100%;
background:#eee;
}
#content {
padding: 10px;
padding-bottom: 100px;
}
#footer {
position: absolute;
bottom: 0;
height: 100px;
width: 100%;
background:lightblue;
}
</style>
</head>
<body>
<div id="main">
<div id="content">
<script type="text/javascript">
for(var i=0; i<400; i++){
document.write(i+'<br/>');
}
</script>
</div>
<div id="footer">
Footer
</div>
</div>
</body>
</html>
方案二:
復(fù)制代碼
代碼如下:<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>css實現(xiàn)頁腳始終在最底部</title>
<style type="text/css">
* {padding: 0;margin: 0;}
html {*overflow: auto;}
body {_width: expression(this.parentNode.clientWidth);}
html,body {height: 100%;}
.section {min-height: 100%;_height: 100%;}
.footer {height: 60px;background: #000;margin-top: -60px;color: #FFF;}
</style>
</head>
<body>
<div class="section">
<script type="text/javascript">
for(var i=0; i<400; i++){
document.write(i+'<br/>');
}
</script>
</div>
<div class="footer">我是頁腳</div>
</body>
</html>
讓頁腳始終固定在屏幕底部:
復(fù)制代碼
代碼如下:<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title></title>
<meta name="generator" content="editplus">
<meta name="author" content="Ariex">
<meta name="keywords" content="">
<meta name="description" content="">
<style type="text/css">
body{margin:0px;padding:0px;overflow:hidden;padding-top:22px;padding-bottom:22px;}
#header{background-color:blue;color:white;position:absolute;top:0px;left:0px;height:16px;width:100%;}
#content{background-color:yellow;width:100%;height:100%;overflow:auto}
#footer{background-color:green;color:white;width:100%;height:16px;position:absolute;bottom:0px;left:0px;}
</style>
<script language="javascript">
</script>
</head>
<body>
<div id="header">header</div>
<div id="content">
<script language="javascript">
for(i=0;i<1000;i++){
document.write(i+"
");
}
</script>
</div>
<div id="footer">footer</div>
</body>
</html>
相關(guān)文章
- 怎么使用Sticky Footer代碼 介紹 Google一下可以找到很多讓頁腳緊貼頁面底部的方法,我試過其中的很多,但他們總會在某些方面存在一些問題。之所以有這些問題,可2009-12-17
CSS實例:讓頁腳保持在未滿屏頁面的底部-CSS教程-網(wǎng)頁制作-網(wǎng)頁教學(xué)網(wǎng)
在內(nèi)容不超過一屏的情況下,當瀏覽器窗口變小那行頁腳文字會跟著向上浮動但還是保持在底部。 當內(nèi)容多出一屏?xí)r,他顯示在網(wǎng)頁的最下邊,而不是窗口的最下邊;測2008-10-17- 本文主要介紹了css讓頁腳保持在底部位置的四種方案,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)2022-07-18