http://www.aygfsteel.com/ebecket 返還網
          隨筆-140  評論-11  文章-131  trackbacks-0

          一直處于頁面底部的div

          看到facebook每個頁面底部的工具欄了嗎?如圖:

          阿斯頓發生大幅

           

          昨天用js寫了一個,代碼如下:

             1:  $(document).ready(function() {
             2:              fixPosition();
             3:   
             4:              $(window).resize(fixPosition).scroll(fixPosition);
             5:          });
             6:   
             7:          function fixPosition() {
             8:   
             9:              $('.bottom').css("top", document.body.offsetHeight + getScrollTop() - 200)
            10:              .css('left', (document.body.offsetWidth - 500) / 2).html(
            11:                  'document.body.offsetHeight:' + document.body.offsetHeight
            12:                  + '<br/>document.body.scrollTop:' + document.body.scrollTop
            13:                  + '<br/>document.body.clientHeight:' + document.body.clientHeight
            14:                  + '<br/>document.body.scrollHeight:' + document.body.scrollHeight
            15:                  + '<br/>document.documentElement.scrollTop:' + document.documentElement.scrollTop
            16:                  + '<br/>' + new Date().toLocaleTimeString());
            17:          }
            18:          function getScrollTop() {
            19:              var scrollPos = 0;
            20:              if (typeof window.pageYOffset != 'undefined') {
            21:                  scrollPos = window.pageYOffset;
            22:              }
            23:              else if (typeof window.document.compatMode != 'undefined' &&
            24:          window.document.compatMode != 'BackCompat') {
            25:                  scrollPos = window.document.documentElement.scrollTop;
            26:              }
            27:              else if (typeof window.document.body != 'undefined') {
            28:                  scrollPos = window.document.body.scrollTop;
            29:              }
            30:              return scrollPos;
            31:          }  
          css代碼:
             1:  .bottom
             2:          {
             3:              position: absolute;
             4:              height: 200px;
             5:              background: #ddd;
             6:              width: 500px;
             7:          }

          不過在ie和firefox下使用的時候都會閃,而facebook的卻一點也不閃,好奇之下用firebug看了看樣式,原來如此:

           

          熱熱人

          原來用css實現了,代碼如下

           

          .bottom
          {
          bottom: 0;
          color: #111111;
          font-size: 11px;
          height: 25px;
          padding: 0;
          position: fixed;
          right: 0;
          width: 100%;
          z-index: 99;
          }	
          試了一下,果然不閃了,特記之。。。
          posted on 2010-01-20 01:29 becket_zheng 閱讀(1095) 評論(0)  編輯  收藏 所屬分類: 網頁web前端技術C#
          主站蜘蛛池模板: 嘉义县| 桃江县| 漳浦县| 镇原县| 和硕县| 安远县| 饶平县| 文水县| 康定县| 青河县| 榆社县| 肇源县| 凤城市| 平陆县| 墨玉县| 甘洛县| 英山县| 上栗县| 余姚市| 沙雅县| 中山市| 吉林市| 河北省| 重庆市| 淅川县| 寿阳县| 黎平县| 通州市| 榕江县| 廊坊市| 蓝山县| 博客| 鹤壁市| 龙里县| 崇信县| 运城市| 富裕县| 霍林郭勒市| 大宁县| 石景山区| 五寨县|