JQuery 写的个性导航菜单
更新时间:2009年12月24日 01:48:46 作者:
浏览者是否对网站感兴趣,前20秒的第一印象至关重要,所以我们的设计要符合大众的期望。下面我们将设计一个个性的导航菜单。
(一):XHTML:
<div id="sidebar">
<ul>
<li><a href="index.html" class="normalMenu">Home</a></li>
<li><a href="services.html" class="normalMenu">Services</a></li>
<li><a href="faq.html" class="normalMenu">FAQ</a></li>
<li><a href="testimonials.html" class="selectedMenu">Testimonials</a></li>
<li><a href="about.html" class="normalMenu">About Alpacas</a></li>
<li><a href="contact.html" class="normalMenu">Contact Us</a></li>
</ul>
</div>
(二):JQuery
$(document).ready(function(){
$('#navigationMenu li .normalMenu').each(function(){
// create a duplicate hyperlink and position it above the current one
$(this).before($(this).clone().removeClass().addClass('hoverMenu'));
});
$('#navigationMenu li').hover(function(){
// we assign an action on mouse over
$(this).find('.hoverMenu').stop().animate({marginTop:'0px'},200);
// the animate method provides countless possibilities
},
function(){
// and an action on mouse out
$(this).find('.hoverMenu').stop().animate({marginTop:'-25px'},200);
});
});
(三)CSS
/* Page styles */
body,h1,h2,h3,p,td,quote,small,form,input,ul,li,ol,label{
margin:0px;
padding:0px;
}
body{
margin-top:20px;
font-family:Arial, Helvetica, sans-serif;
color:#51555C;
height:100%;
font-size:12px;
}
/* Navigation menu styles */
ul{
height:25px;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
ul li{
border:1px solid #444444;
display:inline-block;
float:left;
height:25px;
list-style-type:none;
overflow:hidden;
}
ul li a, ul li a:hover,
ul li a:visited{
text-decoration:none;
}
.normalMenu, .normalMenu:visited,
.hoverMenu, .hoverMenu:visited,
.selectedMenu,.selectedMenu:visited {
outline:none;
padding:5px 10px;
display:block;
}
.hoverMenu,.hoverMenu:visited,
.selectedMenu,.selectedMenu:visited {
margin-top:-25px;
background:url(img/grey_bg.gif) repeat-x #eeeeee;
color:#444444;
}
.selectedMenu,.selectedMenu:visited {
margin:0;
}
.normalMenu, .normalMenu:visited{
color:white;
background:url(img/dark_bg.gif) repeat-x #444444;
}
(四) 效果图
复制代码 代码如下:
<div id="sidebar">
<ul>
<li><a href="index.html" class="normalMenu">Home</a></li>
<li><a href="services.html" class="normalMenu">Services</a></li>
<li><a href="faq.html" class="normalMenu">FAQ</a></li>
<li><a href="testimonials.html" class="selectedMenu">Testimonials</a></li>
<li><a href="about.html" class="normalMenu">About Alpacas</a></li>
<li><a href="contact.html" class="normalMenu">Contact Us</a></li>
</ul>
</div>
(二):JQuery
复制代码 代码如下:
$(document).ready(function(){
$('#navigationMenu li .normalMenu').each(function(){
// create a duplicate hyperlink and position it above the current one
$(this).before($(this).clone().removeClass().addClass('hoverMenu'));
});
$('#navigationMenu li').hover(function(){
// we assign an action on mouse over
$(this).find('.hoverMenu').stop().animate({marginTop:'0px'},200);
// the animate method provides countless possibilities
},
function(){
// and an action on mouse out
$(this).find('.hoverMenu').stop().animate({marginTop:'-25px'},200);
});
});
(三)CSS
复制代码 代码如下:
/* Page styles */
body,h1,h2,h3,p,td,quote,small,form,input,ul,li,ol,label{
margin:0px;
padding:0px;
}
body{
margin-top:20px;
font-family:Arial, Helvetica, sans-serif;
color:#51555C;
height:100%;
font-size:12px;
}
/* Navigation menu styles */
ul{
height:25px;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
ul li{
border:1px solid #444444;
display:inline-block;
float:left;
height:25px;
list-style-type:none;
overflow:hidden;
}
ul li a, ul li a:hover,
ul li a:visited{
text-decoration:none;
}
.normalMenu, .normalMenu:visited,
.hoverMenu, .hoverMenu:visited,
.selectedMenu,.selectedMenu:visited {
outline:none;
padding:5px 10px;
display:block;
}
.hoverMenu,.hoverMenu:visited,
.selectedMenu,.selectedMenu:visited {
margin-top:-25px;
background:url(img/grey_bg.gif) repeat-x #eeeeee;
color:#444444;
}
.selectedMenu,.selectedMenu:visited {
margin:0;
}
.normalMenu, .normalMenu:visited{
color:white;
background:url(img/dark_bg.gif) repeat-x #444444;
}
(四) 效果图
相关文章
jQuery插件bgStretcher.js实现全屏背景特效
可以自动动态更换网页背景图片的jQuery插件bgstretcher.js,sharejs.com推荐的这个插件,可以自定义多种方式让网页背景自动切换,效果流畅,非常难得,调用代码也非常简单。2015-06-06
jQuery-serialize()输出序列化form表单值的方法
jQuery-serialize()输出序列化表单值在工作中很常见也很实用,于是本人搜集整理了一些,需要了解的朋友可以详细参考下2012-12-12
jQuery插件HighCharts实现气泡图效果示例【附demo源码】
这篇文章主要介绍了jQuery插件HighCharts实现气泡图效果,结合完整实例形式分析了jQuery插件HighCharts绘制气泡图的实现技巧,并附带demo源码供读者下载参考,需要的朋友可以参考下2017-03-03


最新评论