search
HomeWeb Front-endJS TutorialJS realizes the black and atmospheric secondary navigation menu effect_javascript skills

The example in this article describes the implementation of a black and atmospheric secondary navigation menu effect using JS. Share it with everyone for your reference. The details are as follows:

This is a good secondary navigation menu made by myself. It is in black style and is based on the imitation of Taobao and Alipay menus. I think it is pretty good.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/js-black-style-2l-nav-menu-codes/

The specific code is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>多级导航菜单</title>
<style>
strong {
 font-style: normal;
 font-weight: normal;
 font-weight: bold;
}
a {
 cursor: pointer;
 text-decoration: none;
}
#container {
 width: 960px;
 margin: 0pt auto;
}
#nav, .nav-container, .nav-container ul, #nav .nav-master-a:hover, #nav .nav-master-a:hover strong, #nav li.current .nav-master-a strong, #nav li.current .nav-master-a, #nav .nav-sub a:hover, #nav .nav-sub a:hover span {
 background-image: url('images/bg-nav.gif');
 background-repeat: no-repeat;
}
#nav {
 position: relative;
 height: 66px;
 margin: 5px 0pt 0pt;
 background-position: 0pt -230px;
 background-repeat: repeat-x;
}
.nav-container {
 padding-left: 15px;
 height: 66px;
 background-position: 0pt 0pt;
}
.nav-container ul {
 height: 100%;
 background-position: right -66px;
}
.nav-container ul ul.nav-sub {
 background: none repeat scroll 0% 0% transparent;
 height: auto;
}
.nav-master {
 display: block;
 float: left;
 height: 36px;
 width: 100px;
 line-height: 36px;
 text-align: center;
 padding-right: 4px;
}
.nav-master-a {
 display: block;
 font-size: 14px;
 height: 26px;
 line-height: 26px;
 overflow: hidden;
 background: none repeat scroll 0% 0% transparent;
 text-decoration: none;
 margin-top: 5px;
}
.nav-master-a strong {
 display: block;
 color: rgb(255, 255, 255);
 height: 100%;
}
li.current .nav-master-a strong, #nav li.current .nav-master-a:hover strong {
 color: rgb(0, 0, 0);
}
.nav-master-a:hover {
 text-decoration: none;
 background-position: 0pt -315px;
}
.nav-master-a:hover strong {
 background-position: right -360px;
}
#nav li.current .nav-master-a strong {
 background-position: right -180px;
 padding-top: 2px;
}
#nav li.current .nav-master-a {
 background-position: 0pt -131px;
 overflow: hidden;
 color: rgb(0, 0, 0);
 height: 31px;
}
#nav li.current .nav-master-a:hover strong {
 color: rgb(0, 0, 0);
}
ul.nav-sub {
 position: absolute;
 width: 920px;
 text-align: left;
 top: 38px;
 left: 20px;
 display: none;
 padding: 2px 0pt 0pt;
 background: none repeat scroll 0% 0% transparent;
}
#nav .current .nav-sub {
 display: block;
}
.nav-sub li {
 float: left;
 display: block;
 width: 78px;
 text-align: center;
 height: 30px;
 overflow: hidden;
 margin-right: 4px;
}
#nav .nav-sub a {
 display: block;
 height: 22px;
 overflow: hidden;
 color: rgb(77, 77, 77);
 text-decoration: none;
}
#nav .nav-sub a span {
 display: block;
 line-height: 22px;
 height: 22px;
}
#nav .nav-sub a:hover {
 background-position: 0pt -405px;
}
#nav .nav-sub a:hover span {
 background-position: right -446px;
}
.sp-nav {
 overflow:hidden;
 background: url(images/bg-nav.gif) repeat-x 0 -595px;
 height:31px;
 line-height:31px
}
.sp-con {
 color:#CCC;
 margin:0 auto;
 width:968px;
}
.sp-l {
 overflow:hidden;
 float:left;
 background:url(images/bg-nav.gif) no-repeat 0 -558px;
 width:6px;
 height:31px
}
.sp-r {
 overflow:hidden;
 float:right;
 background:url(images/bg-nav.gif) no-repeat -6px -558px;
 height:31px;
 width:6px;
}
.sp-m {
 position:relative;
 padding:0 10px;
 float:left;
 background:url(images/bg-nav.gif) repeat-x 0 -495px;
 height:31px;
 line-height:31px;
 width:936px;
 color:#000;
 text-align: left;
}
.other {
 float: left;
 height: 23px;
 margin-right: 22px;
 display: inline;
}
.so {
 float: right;
 padding-top: 6px;
 height: 26px;
}
.so .inputstyleso {
 width: 89px;
 height: 16px;
 line-height: 16px;
 border: 1px solid rgb(190, 190, 190);
 float: left;
 padding-top: 2px;
 padding-left: 5px;
}
.so img {
 float: left;
 margin: 2px 4px 0pt 0pt;
 display: inline;
}
</style>
</head>
<body>
<script language="javascript">
var waitInterval2;
var MDelayTime2=300;/* 设置延时0.3秒 */
function qiehuan(num){
clearTimeout(waitInterval2);
waitInterval2=window.setTimeout("qiehuan2("+num+");",MDelayTime2);
}
function qiehuan2(num){
 clearTimeout(waitInterval2);
 for(var id = 0;id<=9;id++)
 {
 if(id==num)
  {
   document.getElementById("qh_con"+id).style.display="block";
   document.getElementById("mynav"+id).className="nav-master current";
  }
 else
  {
   document.getElementById("qh_con"+id).style.display="none";
   document.getElementById("mynav"+id).className="nav-master";
  }
 }
}
</script>
 <div id="nav">
 <div class="nav-container">
 <ul>
 <li class="nav-master current" id="mynav0"><a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(0)"><strong>首页</strong></a>
  <ul class="nav-sub" id="qh_con0">
  <li><a href="#"><span>最近更新</span></a></li>
  <li><a href="#"><span>热门推荐</span></a></li>
  <li><a href="#"><span>周下载榜</span></a></li>
  <li><a href="#"><span>月下载榜</span></a></li>
  <li><a href="#"><span>相关教程</span></a></li>
  <li><a href="#"><span>美化软件</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav1"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(1)"><strong>xp主题</strong></a>
  <ul class="nav-sub" id="qh_con1">
  <li><a href="#"><span>美女明星</span></a></li>
  <li><a href="#"><span>影视动漫</span></a></li>
  <li><a href="#"><span>清爽系列</span></a></li>
  <li><a href="#"><span>颜色专题</span></a></li>
  <li><a href="#"><span>3D金属</span></a></li>
  <li><a href="#"><span>节日游戏</span></a></li>
  <li><a href="#"><span>汽车体育</span></a></li>
  <li><a href="#"><span>风景设计</span></a></li>
  <li><a href="#"><span>苹果系统</span></a></li>
  <li><a href="#"><span>透明专题</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav2"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(2)"><strong>vista主题</strong></a>
  <ul class="nav-sub" id="qh_con2">
  <li><a href="#"><span>完美套装</span></a></li>
  <li><a href="#"><span>动漫影视</span></a></li>
  <li><a href="#"><span>清爽系列</span></a></li>
  <li><a href="#"><span>美女主题</span></a></li>
  <li><a href="#"><span>3D系列</span></a></li>
  <li><a href="#"><span>汽车主题</span></a></li>
  <li><a href="#"><span>风景主题</span></a></li>
  <li><a href="#"><span>黑色主题</span></a></li>
  <li><a href="#"><span>创意设计</span></a></li>
  <li><a href="#"><span>系统主题</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav3"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(3)"><strong>win7主题</strong></a>
  <ul class="nav-sub" id="qh_con3">
  <li><a href="#"><span>完美套装</span></a></li>
  <li><a href="#"><span>风景主题</span></a></li>
  <li><a href="#"><span>动漫影视</span></a></li>
  <li><a href="#"><span>汽车主题</span></a></li>
  <li><a href="#"><span>清爽系列</span></a></li>
  <li><a href="#"><span>设计主题</span></a></li>
  <li><a href="#"><span>黑色主题</span></a></li>
  <li><a href="#"><span>精美推荐</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav4"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(4)"><strong>屏幕保护</strong></a>
  <ul class="nav-sub" id="qh_con4">
  <li><a href="#"><span>泡泡</span></a></li>
  <li><a href="#"><span>湖泊瀑布</span></a></li>
  <li><a href="#"><span>动物植物</span></a></li>
  <li><a href="#"><span>3D、游戏</span></a></li>
  <li><a href="#"><span>影视卡通</span></a></li>
  <li><a href="#"><span>时钟</span></a></li>
  <li><a href="#"><span>恐怖</span></a></li>
  <li><a href="#"><span>节日、艺术</span></a></li>
  <li><a href="#"><span>水馆族</span></a></li>
  <li><a href="#"><span>自然风光</span></a></li>
  <li><a href="#"><span>太空、火焰</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav5"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(5)"><strong>系统图标</strong></a>
  <ul class="nav-sub" id="qh_con5">
  <li><a href="#"><span>IP包</span></a></li>
  <li><a href="#"><span>苹果</span></a></li>
  <li><a href="#"><span>系统硬件</span></a></li>
  <li><a href="#"><span>生活</span></a></li>
  <li><a href="#"><span>游戏</span></a></li>
  <li><a href="#"><span>节日</span></a></li>
  <li><a href="#"><span>卡通</span></a></li>
  <li><a href="#"><span>文件夹</span></a></li>
  <li><a href="#"><span>回收站</span></a></li>
  <li><a href="#"><span>软件</span></a></li>
  <li><a href="#"><span>手机数码</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav6"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(6)"><strong>鼠标指针</strong></a>
  <ul class="nav-sub" id="qh_con6">
  <li><a href="#"><span>动漫鼠标</span></a></li>
  <li><a href="#"><span>透明系列</span></a></li>
  <li><a href="#"><span>精美特色</span></a></li>
  <li><a href="#"><span>CursorFx/Xp</span></a></li>
  <li><a href="#"><span>鼠标特效</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav7"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(7)"><strong>桌面壁纸</strong></a>
  <ul class="nav-sub" id="qh_con7">
  <li><a href="#"><span>3D、创意</span></a></li>
  <li><a href="#"><span>美女明星</span></a></li>
  <li><a href="#"><span>动物植物</span></a></li>
  <li><a href="#"><span>风景、日历</span></a></li>
  <li><a href="#"><span>节日系列</span></a></li>
  <li><a href="#"><span>影视动漫</span></a></li>
  <li><a href="#"><span>游戏卡通</span></a></li>
  <li><a href="#"><span>PSP、手绘</span></a></li>
  <li><a href="#"><span>炫彩抽象</span></a></li>
  <li><a href="#"><span>人文建筑</span></a></li>
  </ul>
 </li>
 <li class="nav-master" id="mynav8"> <a class="nav-master-a" href="#" onMouseOut="clearTimeout(waitInterval2);" onMouseOver="javascript:qiehuan(8)"><strong>其它美化</strong></a>
  <ul class="nav-sub" id="qh_con8">
  <li><a href="#"><span>启动界面</span></a></li>
  <li><a href="#"><span>登陆界面</span></a></li>
  <li><a href="#"><span>vista边栏</span></a></li>
  <li><a href="#"><span>梦幻桌面</span></a></li>
  <li><a href="#"><span>系统声音</span></a></li>
  <li><a href="#"><span>精选美化包</span></a></li>
  <li><a href="#"><span>相关教程</span></a></li>
  <li><a href="#"><span>美化软件</span></a></li>
  </ul>
 </li>
 </ul>
 </div>
 </div>
</body>
</html>

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

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
如何使用JS和百度地图实现地图平移功能如何使用JS和百度地图实现地图平移功能Nov 21, 2023 am 10:00 AM

如何使用JS和百度地图实现地图平移功能百度地图是一款广泛使用的地图服务平台,在Web开发中经常用于展示地理信息、定位等功能。本文将介绍如何使用JS和百度地图API实现地图平移功能,并提供具体的代码示例。一、准备工作使用百度地图API前,首先需要在百度地图开放平台(http://lbsyun.baidu.com/)上申请一个开发者账号,并创建一个应用。创建完成

js字符串转数组js字符串转数组Aug 03, 2023 pm 01:34 PM

js字符串转数组的方法:1、使用“split()”方法,可以根据指定的分隔符将字符串分割成数组元素;2、使用“Array.from()”方法,可以将可迭代对象或类数组对象转换成真正的数组;3、使用for循环遍历,将每个字符依次添加到数组中;4、使用“Array.split()”方法,通过调用“Array.prototype.forEach()”将一个字符串拆分成数组的快捷方式。

如何使用JS和百度地图实现地图多边形绘制功能如何使用JS和百度地图实现地图多边形绘制功能Nov 21, 2023 am 10:53 AM

如何使用JS和百度地图实现地图多边形绘制功能在现代网页开发中,地图应用已经成为常见的功能之一。而地图上绘制多边形,可以帮助我们将特定区域进行标记,方便用户进行查看和分析。本文将介绍如何使用JS和百度地图API实现地图多边形绘制功能,并提供具体的代码示例。首先,我们需要引入百度地图API。可以利用以下代码在HTML文件中导入百度地图API的JavaScript

如何使用JS和百度地图实现地图热力图功能如何使用JS和百度地图实现地图热力图功能Nov 21, 2023 am 09:33 AM

如何使用JS和百度地图实现地图热力图功能简介:随着互联网和移动设备的迅速发展,地图成为了一种普遍的应用场景。而热力图作为一种可视化的展示方式,能够帮助我们更直观地了解数据的分布情况。本文将介绍如何使用JS和百度地图API来实现地图热力图的功能,并提供具体的代码示例。准备工作:在开始之前,你需要准备以下事项:一个百度开发者账号,并创建一个应用,获取到相应的AP

js中new操作符做了哪些事情js中new操作符做了哪些事情Nov 13, 2023 pm 04:05 PM

js中new操作符做了:1、创建一个空对象,这个新对象将成为函数的实例;2、将新对象的原型链接到构造函数的原型对象,这样新对象就可以访问构造函数原型对象中定义的属性和方法;3、将构造函数的作用域赋给新对象,这样新对象就可以通过this关键字来引用构造函数中的属性和方法;4、执行构造函数中的代码,构造函数中的代码将用于初始化新对象的属性和方法;5、如果构造函数中没有返回等等。

用JavaScript模拟实现打字小游戏!用JavaScript模拟实现打字小游戏!Aug 07, 2022 am 10:34 AM

这篇文章主要为大家详细介绍了js实现打字小游戏,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。

php可以读js内部的数组吗php可以读js内部的数组吗Jul 12, 2023 pm 03:41 PM

php在特定情况下可以读js内部的数组。其方法是:1、在JavaScript中,创建一个包含需要传递给PHP的数组的变量;2、使用Ajax技术将该数组发送给PHP脚本。可以使用原生的JavaScript代码或者使用基于Ajax的JavaScript库如jQuery等;3、在PHP脚本中,接收传递过来的数组数据,并进行相应的处理即可。

js是什么编程语言?js是什么编程语言?May 05, 2019 am 10:22 AM

js全称JavaScript,是一种具有函数优先的轻量级,直译式、解释型或即时编译型的高级编程语言,是一种属于网络的高级脚本语言;JavaScript基于原型编程、多范式的动态脚本语言,并且支持面向对象、命令式和声明式,如函数式编程。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor