var tips; var theTop = 250/*这是默认高度*/; var old = theTop;
function initFloatTips() {
   tips = document.getElementById('floatTips');
   moveTips();
};
function moveTips() {
   var tt=50;
   if (window.innerHeight) {
     pos = window.pageYOffset
   }
   else if (document.documentElement && document.documentElement.scrollTop) {
     pos = document.documentElement.scrollTop
   }
   else if (document.body) {
     pos = document.body.scrollTop;
   }
   pos=pos-tips.offsetTop+theTop;
   pos=tips.offsetTop+pos/10;
   if (pos < theTop) pos = theTop;
   if (pos != old) {
     tips.style.top = pos+"px";
     tt=10;
   }
   old = pos;
   setTimeout(moveTips,tt);
}
 
$(document).ready(function(){
initFloatTips();
})


DIV的ID命名要和JS中的相对应,下面是CSS样式,大家可以自己按需要定义

div#floatTips{
position:absolute;
padding:3px;
bottom:0px;
right:0px;
z-index:9999;
}

本文来源于WEB开发笔记 http://www.chhua.com , 原文地址: http://www.chhua.com/web-note2492

相关文章:

  • 2021-08-03
  • 2022-02-19
  • 2022-01-19
  • 2022-01-16
  • 2022-12-23
  • 2021-12-21
  • 2021-11-15
  • 2021-08-25
猜你喜欢
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2021-11-24
  • 2021-11-24
相关资源
相似解决方案