<u id="14hvx"><sub id="14hvx"></sub></u>

    1. <u id="14hvx"></u>

      <video id="14hvx"><ins id="14hvx"></ins></video>

      品優網絡 十六年(2003-2018)專注
      當前位置:網站首頁 >> 寧波網站建設
      如何在網頁中制作移動的浮動層
      日期:2014-12-18 作者:admin 來源: 瀏覽次數:0 網友評論 0

      企業網站推廣1

      許多人也許會問,好多大型網站上的浮動圖標是怎么實現的呢,在下面這篇文章里就和大家說說:

      前幾步,請將下列原代碼加入html文件的<html>和</html>之間:

      <style type="text/css" media="screen">
      #floater {
      position: absolute;
      left: 500;
      top: 146;
      width: 125;
      visibility: visible;
      z-index: 10;
      }
      -->
      </style>

      **步,請將下列原代碼加入body的任何地方(建議更后):

      <div ID="floater" style="left: 590px; top: 58px">

      <p align="center"><img SRC="../pic/logo.gif" WIDTH="80" HEIGHT="30"><br></p>
      </div><script LANGUAGE="JavaScript">
      self.onError=null;
      currentX = currentY = 0;
      whichIt = null;
      lastScrollX = 0; lastScrollY = 0;
      NS = (document.layers) ? 1 : 0;
      IE = (document.all) ? 1: 0;
      <!-- STALKER CODE -->
      function heartBeat() {
      if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
      if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
      if(diffY != lastScrollY) {
      percent = .1 * (diffY - lastScrollY);
      if(percent > 0) percent = Math.ceil(percent);
      else percent = Math.floor(percent);
      if(IE) document.all.floater.style.pixelTop += percent;
      if(NS) document.floater.top += percent;
      lastScrollY = lastScrollY + percent;
      }
      if(diffX != lastScrollX) {
      percent = .1 * (diffX - lastScrollX);
      if(percent > 0) percent = Math.ceil(percent);
      else percent = Math.floor(percent);
      if(IE) document.all.floater.style.pixelLeft += percent;
      if(NS) document.floater.left += percent;
      lastScrollX = lastScrollX + percent;
      }
      }
      <!-- /STALKER CODE -->
      <!-- DRAG DROP CODE -->
      function checkFocus(x,y) {
      stalkerx = document.floater.pageX;
      stalkery = document.floater.pageY;
      stalkerwidth = document.floater.clip.width;
      stalkerheight = document.floater.clip.height;
      if( (x > stalkerx && x < (stalkerx+stalkerwidth)) && (y > stalkery && y < (stalkery+stalkerheight))) return true;
      else return false;
      }
      function grabIt(e) {
      if(IE) {
      whichIt = event.srcElement;
      while (whichIt.id.indexOf("floater") == -1) {
      whichIt = whichIt.parentElement;
      if (whichIt == null) { return true; }
      }
      whichIt.style.pixelLeft = whichIt.offsetLeft;
      whichIt.style.pixelTop = whichIt.offsetTop;
      currentX = (event.clientX + document.body.scrollLeft);
      currentY = (event.clientY + document.body.scrollTop);
      } else {
      window.captureEvents(Event.MOUSEMOVE);
      if(checkFocus (e.pageX,e.pageY)) {
      whichIt = document.floater;
      StalkerTouchedX = e.pageX-document.floater.pageX;
      StalkerTouchedY = e.pageY-document.floater.pageY;
      }
      }
      return true;
      }
      function moveIt(e) {
      if (whichIt == null) { return false; }
      if(IE) {
      newX = (event.clientX + document.body.scrollLeft);
      newY = (event.clientY + document.body.scrollTop);
      distanceX = (newX - currentX); distanceY = (newY - currentY);
      currentX = newX; currentY = newY;
      whichIt.style.pixelLeft += distanceX;
      whichIt.style.pixelTop += distanceY;
      if(whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
      if(whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
      if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
      if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
      event.returnValue = false;
      } else {
      whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
      if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
      if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
      if( (whichIt.left + whichIt.clip.width) >= (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
      if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
      return false;
      }
      return false;
      }
      function dropIt() {
      whichIt = null;
      if(NS) window.releaseEvents (Event.MOUSEMOVE);
      return true;
      }
      <!-- DRAG DROP CODE -->
      if(NS) {
      window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
      window.onmousedown = grabIt;
      window.onmousemove = moveIt;
      window.onmouseup = dropIt;
      }
      if(IE) {
      document.onmousedown = grabIt;
      document.onmousemove = moveIt;
      document.onmouseup = dropIt;
      }
      if(NS || IE) action = window.setInterval("heartBeat()",1);
      </script>

        修改上面紅色顯示的語句,改為你自己的圖片路徑,并且修改圖片的大小,就完成了!

      如何在網頁中制作移動的浮動層,與大家多多交流。

      企業網站推廣2

      查看更多寧波網站建設網頁如何在

      寧波網站建設 (http://www.mallbillboards.com/) 版權與免責聲明
          1、凡本網注明“來源:寧波品優網絡”字樣的所有作品,版權均屬于浙江省寧波海曙品優網絡技術有限公司,如需轉載、摘編或利用其它方式使用上述作品,請與本網聯系。
          2、凡本網注明“來源:XXX(非寧波品優網絡)”的作品,均轉載自其它媒體,轉載目的在于傳遞更多信息,并不代表本網贊同其觀點和對其真實性負責。寧波網站建設的轉載僅為信息的廣泛傳播,如有侵權請及時告之刪除。
      返回:寧波網站建設
      精品夜夜爽天天爽视频_无码毛片一区二区本码视频_欧美激情免费观看一区_亚洲啪精品视频网站免费
      <u id="14hvx"><sub id="14hvx"></sub></u>

      1. <u id="14hvx"></u>

        <video id="14hvx"><ins id="14hvx"></ins></video>

        在线成人影片免费观看 | 免费人成在线观看99 | 日本三级国产精品一卡两卡 | 一本中文在线精品视频 | 日本中文字幕永久免费 | 亚洲欧美日韩另类精品一区 |