IBM official Chinese website navigation bar fade effect code

From , 5 Years ago, written in JavaScript, viewed 135 times.
URL https://pastebin.vip/view/3cec07e9
  1. <textarea rows="8" id="CodeText17468" class="UBBText"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>IBM官网导航条效果</title>
  6. <style>
  7. body,div,ul,li{margin:0;padding:0;}
  8. body{height:2000px;background:#F0F0F0;}
  9. li{list-style:none;}
  10. a:link,a:visited{outline:none;text-decoration:none;}
  11. #wrap{width:100%;position:fixed;top:0;}
  12. #topBar{color:#7A7A7A;height:28px;background:#131623;overflow:hidden;font:12px/28px Arial;text-align:center;}
  13. #topBar a{color:#FFF;background:#7A7A7A;padding:2px 5px;border-radius:10px;}
  14. #nav{height:50px;overflow:hidden;border-top:1px solid #999;border-bottom::1px solid #666;background:#000 url(http://www.alixixi.com/web/UploadPic/2011-12/2011122131216590.png) repeat-x;}
  15. #nav .logo{float:left;margin:0 20px;}
  16. #nav .logo a{float:left;width:100px;height:50px;overflow:hidden;text-indent:-9999px;background:url(http://www.alixixi.com/web/UploadPic/2011-12/2011122131214364.png) no-repeat;}
  17. #nav .logo a:hover{background-position:0 -50px;}
  18. #nav.hide .logo a{width:100px;height:30px;background-position:0 -100px;_background-position:0 -130px;}
  19. #nav.hide .logo a:hover{background-position:0 -130px;}
  20. #nav ul,#nav ul li{float:left;}
  21. #nav ul li a{float:left;color:#CCC;height:50px;font:16px/50px Arial;padding:0 20px;}
  22. #nav ul li a:hover{color:#FFF;background:url(http://www.alixixi.com/web/UploadPic/2011-12/2011122131216590.png) 0 -50px repeat-x;}
  23. #nav.hide ul{display:none;}
  24. </style>
  25. <script>
  26. var fgm = {
  27.  shit: !-[1,] && !window.XMLHttpRequest,
  28.  scrollTop: function() {
  29.   return document.documentElement.scrollTop || document.body.scrollTop;
  30.  },
  31.  currentStyle: function(obj, attr) {
  32.   return parseInt(obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr]);
  33.  },
  34.  fixed: function(element) {
  35.   if(this.shit) {
  36.    var top = this.currentStyle(element, "top") || 0,
  37.    dd = "(document.documentElement)";
  38.    document.documentElement.style.textOverflow = "ellipsis";
  39.    element.style.position = "absolute";
  40.    element.style.setExpression("top", "eval(" + dd + ".scrollTop + " + (top - this.scrollTop()) + ') + "px"');
  41.   }
  42.   else {
  43.    element.style.position = "fixed";
  44.   }
  45.  },
  46.  doMove: function(obj, iTarget, callback) {
  47.   clearInterval(obj.timer);
  48.   obj.timer = setInterval(function() {
  49.    var iCur = fgm.currentStyle(obj, "height"),
  50.    iSpeed = (iTarget - iCur) / 5;
  51.    iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
  52.    iTarget == iCur ? (clearInterval(obj.timer), callback && callback.call(obj)) : obj.style.height = iSpeed + iCur + "px";
  53.   }, 30);  
  54.  }
  55. };
  56. window.onload = function() {
  57.  var oWrap = document.getElementById("wrap"),
  58.  oTopBar = document.getElementById("topBar"),
  59.  oNav = document.getElementById("nav"),
  60.  fnStatus = function(status) {
  61.   !!status ?
  62.   (function() {
  63.    oNav.className = "hide";
  64.    fgm.doMove(oTopBar, 4);
  65.    fgm.doMove(oNav, 30);
  66.   })() :
  67.   (function() {
  68.    fgm.doMove(oTopBar, 28);
  69.    fgm.doMove(oNav, 50, function() {
  70.     this.className = "" ;
  71.    })
  72.   })();
  73.  };
  74.  fgm.fixed(oWrap);//IE6 Fixed
  75.  window.onscroll = function() {
  76.   var iScrollTop = fgm.scrollTop();
  77.   fnStatus(iScrollTop > 0);
  78.   document.onmouseover = function(ev) {
  79.    var oEv = ev || event,
  80.    oTarget = oEv.target || oEv.srcElement,
  81.    contains = function() {
  82.     if(oWrap.contains) {
  83.      return oWrap.contains(oTarget);
  84.     }
  85.     else if(oWrap.compareDocumentPosition) {
  86.      return !!(oWrap.compareDocumentPosition(oTarget) & 16);
  87.     }
  88.    }();
  89.    fnStatus(!contains && iScrollTop > 0);
  90.   };
  91.  };
  92.  window.onscroll();
  93. };
  94. </script>
  95. </head>
  96. <body>
  97. <div id="wrap">
  98.     <div id="topBar">网页特效提示:用鼠标下拉滚动条查看导航效果,特效转载请注明出处 <a href="http://js.alixixi.com">js.alixixi.com</a> 网页特效频道</div>
  99.     <!--/topBar-->
  100.     <div id="nav">
  101.         <div class="logo"><a href="javascript:;">IBM</a></div>
  102.         <ul>
  103.             <li><a href="javascript:;">解决方案</a></li>
  104.             <li><a href="javascript:;">服务</a></li>
  105.             <li><a href="javascript:;">产品</a></li>
  106.             <li><a href="javascript:;">支持与下载</a></li>
  107.             <li><a href="javascript:;">个性化服务</a></li>
  108.         </ul>
  109.     </div>
  110.     <!--/nav-->
  111. </div>
  112. <!--/wrap-->
  113. </body>
  114. </html>

Reply to "IBM official Chinese website navigation bar fade effect code"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website