国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS實現Fisheye效果動感放大菜單代碼

2019-11-20 11:26:17
字體:
來源:轉載
供稿:網友

本文實例講述了JS實現Fisheye效果動感放大菜單代碼。分享給大家供大家參考,具體如下:

這款Fisheye Menu,是采用JS+CSS+XHTML實現的動感放大菜單,放到圖標上的時候,圖標會被放大,整個菜單有緩沖彈簧的效果,學jQuery的朋友見的比較多,不過本款沒有用到jQuery,效果卻同樣精彩。

運行效果截圖如下:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/js-fisheye-style-menu-demo/

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Fisheye 動感放大的菜單</title><style>#fisheye_menu { list-style: none; padding: 0; margin: 10px; height: 81px;}#fisheye_menu li { position: relative; display: block; float: left;}#fisheye_menu span { position: absolute; top: 100%; left: 0; text-align: center; width: 79px; padding: 1px; margin: 0; border: solid 1px #bbb;  color: #333; background: #eee;}#fisheye_menu a { text-decoration: none;}#fisheye_menu img { border: 0; vertical-align: top;}</style><script type='text/javascript'>var fisheyemenu = { startSize : 55, endSize : 88, imgType : ".gif", init : function () {  var animElements = document.getElementById("fisheye_menu").getElementsByTagName("img");  var titleElements = document.getElementById("fisheye_menu").getElementsByTagName("span");  for(var j=0; j<titleElements.length; j++) {   titleElements[j].style.display = 'none';  }  for(var i=0; i<animElements.length; i++) {   var y = animElements[i];   y.style.width = fisheyemenu.startSize+'px';   y.style.height = fisheyemenu.startSize+'px';   fisheyemenu.imgSmall(y);   animElements[i].onmouseover = changeSize;   animElements[i].onmouseout = restoreSize;  }  function changeSize() {   fisheyemenu.imgLarge(this);   var x = this.parentNode.getElementsByTagName("span");   x[0].style.display = 'block';   if (!this.currentWidth) this.currentWidth = fisheyemenu.startSize;   fisheyemenu.resizeAnimation(this,this.currentWidth,fisheyemenu.endSize,15,10,0.333);  }  function restoreSize() {   var x = this.parentNode.getElementsByTagName("span");   x[0].style.display = 'none';   if (!this.currentWidth) return;   fisheyemenu.resizeAnimation(this,this.currentWidth,fisheyemenu.startSize,15,10,0.5);   fisheyemenu.imgSmall(this);  } }, resizeAnimation : function (elem,startWidth,endWidth,steps,intervals,powr) {  if (elem.widthChangeMemInt) window.clearInterval(elem.widthChangeMemInt);  var actStep = 0;  elem.widthChangeMemInt = window.setInterval(   function() {    elem.currentWidth = fisheyemenu.easeInOut(startWidth,endWidth,steps,actStep,powr);    elem.style.width = elem.currentWidth+"px";    elem.style.height = elem.currentWidth+"px";    actStep++;    if (actStep > steps) window.clearInterval(elem.widthChangeMemInt);   }   ,intervals) }, easeInOut : function (minValue,maxValue,totalSteps,actualStep,powr) {  var delta = maxValue - minValue;  var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);  return Math.ceil(stepp) }, imgSmall : function (obj) {  imgSrc = obj.getAttribute("src");  var typePos = imgSrc.indexOf(fisheyemenu.imgType, 0);  var imgName = imgSrc.substr(0, typePos);  obj.setAttribute("src", imgName+"_small"+fisheyemenu.imgType); }, imgLarge : function (obj) {  imgSrc = obj.getAttribute("src");  var typePos = imgSrc.indexOf("_small", 0);  var imgName = imgSrc.substr(0, typePos);  obj.setAttribute("src", imgName+fisheyemenu.imgType); }}if ( typeof window.addEventListener != "undefined" ) window.addEventListener( "load", fisheyemenu.init, false );else if ( typeof window.attachEvent != "undefined" ) window.attachEvent( "onload", fisheyemenu.init );else { if ( window.onload != null ) { var oldOnload = window.onload; window.onload = function ( e ) {  oldOnload( e );  fisheyemenu.init(); }; } else window.onload = fisheyemenu.init;}</script> </head> <body>  <div>   <ul id="fisheye_menu">    <li><a href="#1"><img src="images/icon.gif" alt="武林網" /><span>Icon 1</span></a></li>    <li><a href="#2"><img src="images/icon2.gif" alt="image description" /><span>Icon 2</span></a></li>    <li><a href="#3"><img src="images/icon.gif" alt="腳本下載" /><span>Icon 3</span></a></li>    <li><a href="#4"><img src="images/icon2.gif" alt="image description" /><span>Icon 4</span></a></li>    <li><a href="#5"><img src="images/icon.gif" alt="VeVB.COm" /><span>Icon 5</span></a></li>    <li><a href="#6"><img src="images/icon2.gif" alt="image description" /><span>Icon 6</span></a></li>   </ul>   </div> </body></html>

希望本文所述對大家JavaScript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 丹寨县| 吉林市| 翁源县| 宁波市| 卢氏县| 克山县| 大荔县| 正安县| 古浪县| 徐汇区| 济阳县| 汝南县| 宜川县| 沈阳市| 高阳县| 桦南县| 合肥市| 高青县| 博客| 贞丰县| 通城县| 溧阳市| 枣庄市| 五指山市| 通河县| 福鼎市| 清镇市| 盐城市| 淮北市| 永新县| 桐柏县| 常州市| 北宁市| 高平市| 山西省| 麻城市| 深水埗区| 砚山县| 汾西县| 响水县| 景德镇市|