Bookmark and Share

Lee's 程序人生

HTML CSS Javascript XML AJAX ATLAS C# C++ 数据结构 软件工程 设计模式 asp.net Java 数字图象处理 Sql 数据库
  博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

让一行页脚保持在底部

Posted on 2008-06-13 10:12  analyzer  阅读(188)  评论(0)    收藏  举报
 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
 2<html xmlns="http://www.w3.org/1999/xhtml">   
 3<head>   
 4<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
 5<title>http://www.zishu.cn</title>   
 6<style>   
 7*{ margin:0; padding:0}    
 8#info{background:#33CCFF}    
 9#bottom{background:#FFCC00;width:100%;}    
10
</style>   
11</head>   
12<body>   
13<div id="info">   
14<br />2<br />2<br />2<br /><br />2<br />2<br />2<br />2<br />2<br />2<br />2<br />2<br /><br />2<br />2<br />2<br />2<br />2<br /><br />2<br />2<br />2<br />2<br />2<br /><br />2<br />2<br />2<br />2<br />2<br /><br />2<br />20000</div>   
15<div id="bottom">bottom</div>   
16   
17<script language="JavaScript" type="text/javascript">   
18function test(){    
19 var infoHeight = document.getElementById("info").scrollHeight;    
20 var bottomHeight = document.getElementById("bottom").scrollHeight;    
21 var allHeight = document.documentElement.clientHeight;    
22     
23 var bottom = document.getElementById("bottom");    
24 if((infoHeight + bottomHeight) < allHeight){    
25  bottom.style.position = "absolute";    
26  bottom.style.bottom = "0";    
27 }
else{    
28  bottom.style.position = "";    
29  bottom.style.bottom = "";    
30 }
     
31     
32 setTimeout(function(){test();},10);    
33}
    
34test();    
35
</script>   
36</body>   
37</html>   
38