21视频教程网3月27日整理
苹果风格的导航是比较炫酷的,用YUI3模仿这种导航风格。当鼠标移至菜单上,图标上移至顶部,然后滑动至展示区;鼠标移出时,图标移至导航下方,滑动至菜单后隐藏。效果如下:
直接上代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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="http://www.microidc.com/demo/style.css">
<link rel="stylesheet" type="text/css" href="http://www.microidc.com/demo/yui-applestyle-navigation/style.css">
</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 © 2010 <a href="http://www.microidc.com" title="microidc">不名一格</a></p>
<p>Please send bug reports to idd.chiang[At]gmail.com</p>
</div>
<script type="text/javascript" src="http://cn.yimg.com/i/yui/3.0.0/build/yui/yui-min.js"></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:"http://cn.yimg.com/combo?",
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>
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |