DivCSS實例:讓頁腳保持在未滿屏頁面的底部_Div+CSS教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!
        DivCSS實例:讓頁腳保持在未滿屏頁面的底部

        在內容不超過一屏的情況下,當瀏覽器窗口變小那行頁腳文字會跟著向上浮動但還是保持在底部。
        當內容多出一屏時,他顯示在網頁的最下邊,而不是窗口的最下邊;測試了一下,還可以,在IE6、IE7、FF等都沒有問題!窗口縮小時也沒有問題!

        首先是JS腳本:

      示例代碼 [www.wf0088.com]
      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();

        查看運行效果:

      代碼調試框 [www.wf0088.com]

      [ 可先修改部分代碼 再運行查看效果 ]

        

      /所屬分類:Div+CSS教程/更新時間:2008-06-05
      相關Div+CSS教程