当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JQuery 写的个性导航菜单

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 JQuery 写的个性导航菜单


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 357 ::
收藏到网摘: n/a

浏览者是否对网站感兴趣,前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;
}

(四) 效果图