Home  >  Article  >  Web Front-end  >  jQuery ui implements dynamic rounded gradient website navigation menu effect code_jquery

jQuery ui implements dynamic rounded gradient website navigation menu effect code_jquery

WBOY
WBOYOriginal
2016-05-16 15:42:261260browse

The example in this article describes the jQuery ui implementation of dynamic rounded corner gradient website navigation menu effect code. Share it with everyone for your reference. The details are as follows:

Today I will share with you a website gradient navigation menu based on jQuery UI. It can be used as the main navigation with a fade-in and fade-out effect. After the mouse moves over the menu, the menu items will display a rounded background. When testing locally, please pay attention For the several JS script files introduced, it is best to save them locally, and the menu compatibility is also good.

Let’s take a look at the screenshots of the running effect:

The online demo address is as follows:

http://demo.jb51.net/js/2015/jquery-ui-cicle-button-style-web-nav-codes/

The specific code is as follows:

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery动态效果导航菜单</title>
<style type="text/css">
<!--
@import url(http://fonts.googleapis.com/css&#63;family=Lobster);
body {margin:0; padding:0; background:#ddd;}
#nav{position:relative; margin:40px; background:#eee; padding:0; font-family:'Lobster', Arial, Helvetica, sans-serif; font-size:21px; -moz-border-radius:5px; -khtml-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; -moz-box-shadow:2px 2px 3px #ccc; -webkit-box-shadow:2px 2px 3px #ccc; box-shadow:2px 2px 3px #ccc;}
#nav .clear{clear:both;}
#nav ul{padding:0 0 0 5px; margin:0; list-style:none;}
#nav li{float:left; margin:5px 10px 5px 0; background:#eee; -moz-border-radius:5px; -khtml-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
#nav li a{text-decoration:none; color:#9e0039; display:block; padding:10px 15px;}
-->
</style>
<script src="js/jquery-1.6.2.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<!-- rounded corners for IE -->
<script src="js/DD_roundies_0.0.2a-min.js"></script>
<script>
DD_roundies.addRule("#nav", "5px");
DD_roundies.addRule("#nav li", "5px");
</script>
<script>
$(document).ready(function(){
 $nav_li=$("#nav li");
 $nav_li_a=$("#nav li a");
 var animSpeed=450; //fade speed
 var hoverTextColor="#fff"; //text color on mouse over
 var hoverBackgroundColor="#9e0039"; //background color on mouse over
 var textColor=$nav_li_a.css("color");
 var backgroundColor=$nav_li.css("background-color");
 //text color animation
 $nav_li_a.hover(function() {
  var $this=$(this);
  $this.stop().animate({ color: hoverTextColor }, animSpeed);
 },function() {
  var $this=$(this);
  $this.stop().animate({ color: textColor }, animSpeed);
 });
 //background color animation
 $nav_li.hover(function() {
  var $this=$(this);
  $this.stop().animate({ backgroundColor: hoverBackgroundColor }, animSpeed);
 },function() {
  var $this=$(this);
  $this.stop().animate({ backgroundColor: backgroundColor }, animSpeed);
 });
});
</script>
</head>
<body>
<div id="nav">
<ul>
 <li><a href="#about">关于我</a></li>
 <li><a href="#portfolio">配置说明</a></li>
 <li><a href="#recent">回收清单</a></li>
 <li><a href="#experiments">心情速递</a></li>
 <li><a href="#contact">联系我</a></li>
 </ul>
 <div class="clear"></div>
</div>
</body>
</html>

I hope this article will be helpful to everyone’s jquery programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn