JS技术

Javascript实现漂亮苹果风格导航菜单源码_Javascript教程

字号+ 作者:H5之家 来源:H5之家 2015-10-01 11:11 我要评论( )

Javascript实现漂亮苹果风格导航菜单源码,学习Javascript实现漂亮苹果风格导航菜单源码,Javascript实现漂亮苹果风格导航菜单源码,查看Javascript实现漂亮苹果风

教程网3月28日整理

苹果风格的导航是比较炫酷的,用YUI3模仿这种导航风格。当鼠标移至菜单上,图标上移至顶部,然后滑动至展示区;鼠标移出时,图标移至导航下方,滑动至菜单后隐藏。效果如下:



直接上代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html lang="zh">
<head>
 <title>YUI仿苹果风格图标滑出导航菜单 - Tutorial - 不名一格</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <meta name="author" content="idd.chiang@gmail.com" />
 <meta name="description" content="Demo for YUI仿苹果导航菜单" />
 <meta name="keywords" content="css,js,YUI,apple-style, apple, apple-like, beautiful, tutorial, menu, navigation, icons" />
 <link rel="stylesheet" type="text/css" href="">
 <link rel="stylesheet" type="text/css" href="">
</head>
<body class="yui-skin-sam">
<div id="doc" class="demo">
 <div id="hd">
  <div class="page-title">
   <h1>Apple-Style Slide Out Navigation Menu by YUI</h1>
  </div>
 </div>
 <div id="bd">
  <h2>Tutorial:YUI仿苹果风格图标滑出导航菜单</h2>
  <p>IE7、FF3.5、safari、opera、chrome下测试通过,IE8无环境未测。</p>
  <p><br/></p>
  <!-- {{ Content -->
  <div class="navigation">
            <ul class="menu fl" id="menu">
                <li><span class="game"><br/></span><a href="#" class="first">Game</a></li>
                <li><span class="water"><br/></span><a href="#">Water</a></li>
                <li><span class="code"><br/></span><a href="#">Coding</a></li>
                <li><span class="tools"><br/></span><a href="#">ToolsBox</a></li>
                <li><span class="curve"><br/></span><a href="#">Curve</a></li>
                <li><span class="options"><br/></span><a href="#" class="last">Options</a></li>
            </ul>
        </div>
  <!-- }} Content -->
 </div>
 <div id="ft">
  <p>Copyright &#169; 2010 <a href="" title="microidc">不名一格</a></p>
  <p>Please send bug reports to idd.chiang[At]gmail.com</p>
 </div>
 <script type="text/javascript" src=""></script>
        <script type="text/javascript">
   <!--
   YUI({
    //Combo JS
    combine:true,
    base:'http://cn.yimg.com/i/yui/3.0.0/build/',
    root:"i/yui/3.0.0/build/", 
    comboBase:"?",
    charset:'utf-8',
    loadOptional:true
   }).use('node','anim',function(Y) {
    var _menu = Y.one('#menu'),
     _li = _menu.queryAll('li'),
     _a = _menu.queryAll('li a'),
     _span = _menu.queryAll('li span');
    //初始化
    _menu.setStyle('zIndex','2');
    _a.setStyle('zIndex','1');
    _span.setStyle('zIndex','-1');
    _span.each(function(node){
     var anim = new Y.Anim({
      node:node,
      from:{
       top:'10'
      },
      to:{
       top:'-23'
      },
      easing: Y.Easing.backIn
     });
     anim.run();
    });
    //鼠标移上效果
    /* @Y.delegate 事件委派
     * EventHandle delegate  ( type , fn , el , spec , context , args* )
     * el  <string|node>    委派元素 
     * spec  <string>    匹配目标事件的选择器
     */
    Y.delegate('mouseover', function(e){
     var _span = this.one('span'),
      _a = this.one('a');
     _a.addClass('hover');
     _span.setStyle('zIndex','1');
     var anim = new Y.Anim({
      node:_span,
      to:{
       top:45
      },
      duration: 0.3
     });
     anim.run();
    }, '#menu', 'li');
    Y.delegate('mouseout', function(e){
     var _span = this.one('span'),
      _a = this.one('a');
     _a.removeClass('hover');
     _span.setStyle('zIndex','-1');
     var anim = new Y.Anim({
      node:_span,
      to:{
       top:-23
      },
      duration: 0.3,
      easing: Y.Easing.backIn
     });
     anim.run();
    }, '#menu', 'li');
   }); 
   //-->
        </script>
</div>
</body>
</html>

Javascript教程

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • JavaScript入门教程(二)_javascript教程教程

    JavaScript入门教程(二)_javascript教程教程

    2015-10-10 14:25

  • JavaScript入门教程(五)_javascript教程教程

    JavaScript入门教程(五)_javascript教程教程

    2015-10-10 14:21

  • JavaScript入门教程(四)_javascript教程教程

    JavaScript入门教程(四)_javascript教程教程

    2015-10-10 14:19

  • JavaScript入门教程(三)_javascript教程教程

    JavaScript入门教程(三)_javascript教程教程

    2015-10-10 14:17

网友点评