国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

CSS實例:讓頁腳保持在未滿屏頁面的底部

2024-07-11 08:20:59
字體:
來源:轉載
供稿:網友

  在內容不超過一屏的情況下,當瀏覽器窗口變小那行頁腳文字會跟著向上浮動但還是保持在底部。

  當內容多出一屏時,他顯示在網頁的最下邊,而不是窗口的最下邊;測試了一下,還可以,在ie6、ie7、ff等都沒有問題!窗口縮小時也沒有問題!

  首先是js腳本:

function test(){
 var infoheight = document.getelementbyid("info").scrollheight;
 var bottomheight = document.getelementbyid("bottom").scrollheight;
 var allheight = document.documentelement.clientheight;
 var bottom = document.getelementbyid("bottom");
 if((infoheight + bottomheight) < allheight){
  bottom.style.position = "absolute";
  bottom.style.bottom = "0";
 }else{
  bottom.style.position = "";
  bottom.style.bottom = "";
 }
 settimeout(function(){test();},10);
}
test();

  查看運行效果:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>css實例:讓頁腳保持在未滿屏頁面的底部</title>
<style>
*{ margin:0; padding:0}
#info{background:#33ccff}
#bottom{background:#ffcc00;width:100%;}
</style>
</head>
<body>
<div id="info">
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>
<div id="bottom">bottom</div>
<script language="javascript" type="text/javascript">
function test(){
 var infoheight = document.getelementbyid("info").scrollheight;
 var bottomheight = document.getelementbyid("bottom").scrollheight;
 var allheight = document.documentelement.clientheight;
 
 var bottom = document.getelementbyid("bottom");
 if((infoheight + bottomheight) < allheight){
  bottom.style.position = "absolute";
  bottom.style.bottom = "0";
 }else{
  bottom.style.position = "";
  bottom.style.bottom = "";
 }
 settimeout(function(){test();},10);
}
test();
</script>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 通州区| 凌海市| 萍乡市| 温宿县| 梨树县| 阿城市| 台江县| 汤原县| 静安区| 忻城县| 尖扎县| 天长市| 招远市| 光泽县| 长海县| 保德县| 天祝| 梁河县| 陆良县| 金坛市| 金乡县| 白城市| 连平县| 商都县| 平顶山市| 上高县| 珠海市| 揭东县| 通山县| 辽阳县| 松原市| 深州市| 新乐市| 清水县| 平南县| 五台县| 宝应县| 青神县| 德惠市| 甘孜| 乌兰察布市|