国产探花免费观看_亚洲丰满少妇自慰呻吟_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>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 盱眙县| 醴陵市| 历史| 鹰潭市| 抚远县| 五家渠市| 建瓯市| 商南县| 隆子县| 隆林| 莎车县| 达日县| 纳雍县| 健康| 阿克苏市| 花垣县| 湄潭县| 临西县| 谢通门县| 霸州市| 开原市| 濮阳市| 克拉玛依市| 平乡县| 周至县| 屯昌县| 察隅县| 苍山县| 巢湖市| 栾城县| 长武县| 峡江县| 全南县| 江口县| 乾安县| 咸丰县| 梅州市| 加查县| 敦煌市| 保山市| 桐梓县|