主要用于运维系统, 对界面要求不高的场合。  深深感到自己页面设计能力弱爆了,只能借鉴一下了, 交互逻辑还可以胜任一点。

直接贴代码:

1.  HTML 页面及 JS 交互, 注意引入 Jquery 文件

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>两级导航菜单的示例</title>
<script src="jquery-1.10.1.min.js"></script> <!-- moonmm css -->
<link rel="stylesheet" type="text/css" href="two-nav.css" />
<script type="text/javascript"> var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
function showtime() {
var date = new Date();
var yy = date.getYear();
if (yy < 1900) {
yy = yy + 1900;
}
var MM = date.getMonth()+1;
if(MM<10) MM = '0' + MM;
var dd = date.getDate();
if(dd<10) dd = '0' + dd;
var hh = date.getHours();
if(hh<10) hh = '0' + hh;
var mm = date.getMinutes();
if(mm<10) mm = '0' + mm;
var ss = date.getSeconds();
if(ss<10) ss = '0' + ss;
var ww = weeks[date.getDay()];
$('#currTime span').html('[ ' + yy + '-' + MM + '-' + dd + ' ' + hh + ':' + mm + ':' + ss + ' ' + ww + ' ]');
window.setTimeout("showtime()", 1000);
} var setContentSize = function(height, width) {
$('header').css('width', width);
$('#topnav').css('width', width);
$('#nav').css('width', width);
$('#content').css('height', height + 'px');
$('#content').css('width', width);
$('#maincontent').css('height', height + 'px' );
$('#maincontent').css('width', width);
} $(document).ready(
function() { var docHeight = $(document).outerHeight();
var docWidth = $(document).width();
var headerHeight = $('#header').height();
var contentHeight = docHeight-headerHeight; $('#topnav a').click(
function() {
$('.select').removeClass('select');
$(this).addClass('select');
console.log($(this).css('background-color'));
$('#nav').css('background-color', $(this).css('background-color'));
$('#nav').css('width', $('#topnav').width());
switch(this.id) {
case 'topmenu_home':
$('.nav_list').hide();
$('#homebo').show();
$('#homebo a').first().click();
break;
case 'topmenu_itlearn':
$('.nav_list').hide();
$('#itlearnbo').show();
$('#itlearnbo a').first().click();
break;
case 'topmenu_baike':
$('.nav_list').hide();
$('#baikebo').show();
$('#baikebo a').first().click();
break;
case 'topmenu_scisrc':
$('.nav_list').hide();
$('#scisrcbo').show();
$('#scisrcbo a').first().click();
break;
case 'topmenu_more':
$('.nav_list').hide();
$('#morebo').show();
$('#morebo a').first().click();
break;
default : break;
} }
); $('#nav a').click(
function() {
setContentSize(contentHeight, docWidth-15);
$('#nav .select').removeClass('select');
$(this).addClass('select');
switch(this.id) {
case 'myblogModule':
$('#maincontent').attr('src', 'http://blog.csdn.net/lovesqcc');
break;
case 'ifeveModule':
setContentSize(contentHeight+80, docWidth-15);
$('#maincontent').attr('src', 'http://ifeve.com/');
break;
case 'csdnModule':
$('#maincontent').attr('src', 'http://csdn.net');
break;
case 'infoqModule':
$('#maincontent').attr('src', 'http://www.infoq.com/cn/');
break;
case 'boleModule':
$('#maincontent').attr('src', 'http://blog.jobbole.com/');
break;
case 'itcommentModule':
$('#maincontent').attr('src', 'http://www.vaikan.com/');
break;
case 'wikiModule':
$('#maincontent').attr('src', 'http://zh.wikipedia.org/zh-tw/Wikipedia');
break;
case 'zhihuModule':
$('#maincontent').attr('src', 'http://www.zhihu.com/');
break;
case 'acmModule':
$('#maincontent').attr('src', 'http://www.acm.org/');
break;
case 'xiamiModule':
$('#maincontent').attr('src', 'http://www.xiami.com');
break;
case 'opencourseModule':
$('#maincontent').attr('src', 'http://v.163.com/special/ted10collection/');
break;
default:
break;
} }
);
$('.nav_list').hide();
$('#topmenu_home').click();
showtime();
}
);
</script>
</head>
<body>
<div id="header">
<div id="firstHeader">
<div id="logo"> 两级导航菜单 </div>
<div id="target">两级导航菜单的示例</div>
<div id="toolbar">
<a href="#" id="userinfo">[ 你好: <span style="color:#f47920">admin</span> ]</a>
<a href="#" id="currTime"><span></span></a>
<a href="http://aone.alibaba-inc.com/aone2/req/addFromProductline/9139" target="_blank"><span style="color:#f47920">[ 提建议 ]</span></a>
</div>
</div>
<div class="clear"></div>
<div id="topnav">
<div class="topnav_list">
<a href="#" class="select" id="topmenu_home"><span>首页</span></a>
<a href="#" id="topmenu_itlearn"><span>IT学习</span></a>
<a href="#" id="topmenu_baike"><span>百科</span></a>
<a href="#" id="topmenu_scisrc"><span>学术资源</span></a>
<a href="#" id="topmenu_more"><span>更多</span></a>
</div>
</div>
<div class="clear"></div> <div id="nav"> <div class="nav_list" id="homebo">
<a href="#" class="select" id="myblogModule"><span>我的博客</span></a>
</div> <div class="nav_list" id="itlearnbo">
<a href="#" class="select" id="ifeveModule"><span>并发编程网</span></a>
<a href="#" id="csdnModule"><span>CSDN</span></a>
<a href="#" id="infoqModule"><span>Infoq</span></a>
<a href="#" id="boleModule"><span>伯乐在线</span></a>
<a href="#" id="itcommentModule"><span>外刊评论</span></a>
</div> <div class="nav_list" id="baikebo">
<a href="#" class="select" id="wikiModule"><span>WIKI百科</span></a>
<a href="#" id="zhihuModule"><span>知乎</span></a>
</div> <div class="nav_list" id="scisrcbo">
<a href="#" class="select" id="acmModule"><span>ACM</span></a>
</div> <div class="nav_list" id="morebo">
<a href="#" class="select" id="xiamiModule"><span>虾米音乐</span></a>
<a href="#" id="opencourseModule"><span>网易公开课</span></a>
</div> </div>
</div>
<div id="content">
<iframe id="maincontent" frameborder="0" width="100%"></iframe>
</div> </body>
</html>

2.  CSS 文件

 div:not(#topnav, #logo){font-size:10pt!important}
*{font-family: 微软雅黑, 宋体, san-serif!important} /*
* Header CSS
*/ a{color:#2F649A;}
a:link{text-decoration:none;}
a:visited{text-decoration:none;}
a:hover{text-decoration:underline;}
a:active{text-decoration:none;} body {
background-color: #dae7f6;
margin: -0px -0px;
} #firstHeader {
height: 56px;
} #logo {
float: left;
font-size: 28pt;
margin: 10px 0px 10px 20px;
font-family: 隶书, 微软雅黑, 宋体, san-serif!important;
} #target {
float: left;
font-size: 10.5pt;
font-style: italic;
font-weight: 1.5em;
margin: 25px 30px 0px 5px;
} #toolbar {
float: right;
margin: 0px 3px;
} #toolbar a {
font-size: 10pt;
} #content {
background-color: #45b97c;
} /* the top menu */
#topnav {
float: left;
background-color: #426ab3;
width: 100%;
} #topnav .topnav_list {
float:left; width: 100%; height:29px; color:#333; margin: 0px 0px -1px 0px;
font-size: 11pt!important; font-weight:bold;
border-radius: 5px;
} #topnav .topnav_list a {
display:inline-block; height:24px; padding: 2px 0 2px 18px;
color:#fff; vertical-align:middle; line-height:22px; *line-height:24px; cursor:pointer;
border-radius: 5px; border-right: 2px outset #00BFFF;
} #topnav .topnav_list a span {
display:inline-block; height:22px; padding:0 20px 0 0;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
} #topnav .topnav_list a:hover, #topnav .topnav_list a.select {
position:relative; z-index:;
background-color: #45b97c;
color:#fff; text-decoration:none;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
} #topnav .topnav_list a:hover span, #topnav .topnav_list a.select span {
background-color: #45b97c;
color:#fff;
border-radius: 5px;
} .clear {
clear: both;
} /* the first menu */
#nav {
font-size: 10pt;
} #nav .nav_list {
float:left; padding: 3px 0 3px 0; font-weight:bold;height:25px;
} #nav .nav_list a {
display:inline-block;
padding: 2px 15px 2px 15px;
color:#fff; vertical-align:middle; line-height:22px; *line-height:24px; cursor:pointer;
border-radius: 8px;
border-radius: 8px;
} #nav .nav_list a span {
display:inline-block;
border-radius: 8px;
border-radius: 8px;
} #nav .nav_list a:hover, #nav .nav_list a.select {
position:relative; z-index:;
text-decoration:none;
border-radius: 8px;
border-radius: 8px;
} #nav .nav_list a:hover, #nav .nav_list a:hover span {
background-color: #007d65;
color: #fff;
} #nav .nav_list a.select, #nav .nav_list a.select span {
background-color: #fff;
color: #ca0000;
}

 3.  效果图

jquery 实现两级导航菜单的更多相关文章

  1. JQUERY 插件开发——MENU(导航菜单)

    JQUERY 插件开发——MENU(导航菜单) 故事背景:由于最近太忙了,已经很久没有写jquery插件开发系列了.但是凭着自己对这方面的爱好,我还是抽了一些时间来过一下插件瘾的.今天的主题是导航菜单 ...

  2. 如何用CSS和jQuery实现一个侧滑导航菜单

    为了建立导航菜单,让我们先看看html结构:<!DOCTYPE html><html lang="en"><head> <meta cha ...

  3. jquery火焰等效果导航菜单

    jQuery-火焰灯效果导航菜单 by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu.com/wordpre ...

  4. css3和jquery实现的可折叠导航菜单(适合手机网页)

    之前为大家介绍了好几款css3导航,今天为大家在介绍的是一款适合放在手机网页的导航菜单.点击列表图标以下拉式的形式显示菜单,单击关闭,动画关闭.效果相当不错.效果图如下: 在线预览   源码下载 这个 ...

  5. jquery倾斜的动画导航菜单

    1. [代码]完整源代码  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http ...

  6. Jquery列表中的导航菜单的应用

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  7. 利用jquery实现百度新闻导航菜单滑动动画

    前言 前两天,群里有人问百度新闻导航是如何实现的,当时由于忙于工作,没有来得及细看,恰好今天有空闲时间,索性就实现一下这个效果吧: 思路与步骤 1.利用UL创建简单横向导航: <!DOCTYPE ...

  8. 【Web】利用jquery实现百度新闻导航菜单滑动动画

    前言 前两天,群里有人问百度新闻导航是如何实现的,当时由于忙于工作,没有来得及细看,恰好今天有空闲时间,索性就实现一下这个效果吧: 思路与步骤 1.利用UL创建简单横向导航: <!DOCTYPE ...

  9. Jquery实现两级联动

    最后结果如下: 关键代码如下: <select name="customerCondition['credibilityBegin']" id="credibili ...

随机推荐

  1. [通信] C# TCP实现多个客户端与服务端 数据 与 文件的传输

    说明: http://download.csdn.net/detail/chwei_cson/4423874 源码: http://download.csdn.net/download/meicanj ...

  2. php----空字符串的和NULL的区别

    空字符串和null的区别是非常的大的,虽然都是没有任何东西,但是空字符串会占据一个内存,只是在这里内存里面没有东西而已,但是null就是完全不存在这个东西,他是不会开辟内存. $str1 = &quo ...

  3. 从UE(用户体验)到道家誓学再到李小龙

    公司大Boss经常会给我做技术培训,感觉他什么都知道,也挺喜欢听他的课. 本文记录可能比较天马行空,我的语文比较差,很难把自己想表达的说出来,为此我就是记录一样关键字,可能这样还会更好些 背景是讲用户 ...

  4. POJ-1887 Testing the CATCHER(dp,最长下降子序列)

    Testing the CATCHER Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16515 Accepted: 6082 ...

  5. 在ubuntu下安装使用latex

    参考:https://www.cnblogs.com/longdouhzt/archive/2012/09/27/2706358.html https://jingyan.baidu.com/albu ...

  6. 安装XP时BIOS的设置(ahci ide)

    和以前使用Windows XP一样,很多用户都在设法提高Windows 7的系统运行速速,比较常见的方法大多是对系统服务进行优化,去掉一些可有可无的系统服务,还有就是优化资源管理器菜单等.除此之外,还 ...

  7. 关于LeNet-5卷积神经网络 S2层与C3层连接的参数计算的思考???

    https://blog.csdn.net/saw009/article/details/80590245 关于LeNet-5卷积神经网络 S2层与C3层连接的参数计算的思考??? 首先图1是LeNe ...

  8. sql中select into和insert into的区别

    select into主要是作用于没有新建表,在复制数据的时候新建 insert into主要作用于已经新建了一个表,直接把要复制的数据复制到新建好的表中

  9. Python 字典 dict() 函数

    描述 Python 字典 dict() 函数用于创建一个新的字典,用法与 Pyhon 字典 update() 方法相似. 语法 dict() 函数函数语法: dict(key/value) 参数说明: ...

  10. grunt学习三-bower(一)

    bower是什么?官网给出的  a package manager fow the web.简单说引入文件版本管理,例如jquery,传统做法到jquery的官网下载下,在引入,这样比较繁琐,也不利用 ...