栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

基于jQuery实现左侧菜单栏可折叠功能

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于jQuery实现左侧菜单栏可折叠功能

今天给大家介绍一下左侧菜单栏可折叠功能,在后台管理中左侧菜单折叠功能是特别常见的一个功能,基本不管是什么类型的管理后台都会涉及到这个功能的实现。

今天给大家介绍的是二级可折叠菜单的功能,相对一级的菜单折叠功能就显得稍微比较复杂一点了,我这里将给大家介绍菜单折叠过程中三种变换形式。

第一种变换形式是:不管点击哪一级菜单都可以打开或者关闭本级菜单,但是不会影响其他级别的菜单:




 
 jQuery点击展开收缩树形菜单
 
 *{margin: 0;padding: 0}
 body{font-size: 12px;font-family: "宋体","微软雅黑";}
 ul,li{list-style: none;}
 a:link,a:visited{text-decoration: none;color: #fff;}
 .list{width: 210px;border-bottom:solid 1px #316a91;margin:40px auto 0 auto;}
 .list ul li{background-color:#467ca2; border:solid 1px #316a91; border-bottom:0;}
 .list ul li a{padding-left: 10px;color: #fff; font-size:12px; display: block; font-weight:bold; height:36px;line-height: 36px;position: relative;
 }
 .list ul li .inactive{ background:url(images/off.png) no-repeat 184px center;}
 .list ul li .inactives{background:url(images/on.png) no-repeat 184px center;} 
 .list ul li ul{display: none;}
 .list ul li ul li { border-left:0; border-right:0; background-color:#6196bb; border-color:#467ca2;}
 .list ul li ul li ul{display: none;}
 .list ul li ul li a{ padding-left:20px;}
 .list ul li ul li ul li { background-color:#d6e6f1; border-color:#6196bb; }
 .last{ background-color:#d6e6f1; border-color:#6196bb; }
 .list ul li ul li ul li a{ color:#316a91; padding-left:30px;}
 
 
 


 
  
  • 中国美协章程
  • 中国文联美术艺术中心
    • 综合部
    • 大型活动部
    • 展览部
    • 艺委会工作部
    • 信息资源部
    • 双年展办公室
  • 组织机构
    • 美协机关
      • 办公室
      • 人事处
      • 组联部
      • 外联部
      • 研究部
      • 维权办
    • 中国文联美术艺术中心
      • 综合部
      • 大型活动部
      • 展览部
      • 艺委会工作部
      • 信息资源部
      • 双年展办公室
    • 《美术》杂志社
  • 组织机构
    • 美协机关
      • 办公室
      • 人事处
      • 组联部
      • 外联部
      • 研究部
      • 维权办
    • 中国文联美术艺术中心
      • 综合部
      • 大型活动部
      • 展览部
      • 艺委会工作部
      • 信息资源部
      • 双年展办公室
    • 《美术》杂志社

运行截图为:

第二种变换形式是:一级菜单会互相影响,也就是一级菜单同时只能打开一个,其他都得处于关闭状态。但是二级菜单下的开闭不会受到影响,也就是二级菜单本来是什么状态,点击任意一级菜单之后还是相应的状态。




 
 jQuery点击展开收缩树形菜单
 
 *{margin: 0;padding: 0}
 body{font-size: 12px;font-family: "宋体","微软雅黑";}
 ul,li{list-style: none;}
 a:link,a:visited{text-decoration: none;color: #fff;}
 .list{width: 210px;border-bottom:solid 1px #316a91;margin:40px auto 0 auto;}
 .list ul li{background-color:#467ca2; border:solid 1px #316a91; border-bottom:0;}
 .list ul li a{padding-left: 10px;color: #fff; font-size:12px; display: block; font-weight:bold; height:36px;line-height: 36px;position: relative;
 }
 .list ul li .inactive{ background:url(images/off.png) no-repeat 184px center;}
 .list ul li .inactives{background:url(images/on.png) no-repeat 184px center;} 
 .list ul li ul{display: none;}
 .list ul li ul li { border-left:0; border-right:0; background-color:#6196bb; border-color:#467ca2;}
 .list ul li ul li ul{display: none;}
 .list ul li ul li a{ padding-left:20px;}
 .list ul li ul li ul li { background-color:#d6e6f1; border-color:#6196bb; }
 .last{ background-color:#d6e6f1; border-color:#6196bb; }
 .list ul li ul li ul li a{ color:#316a91; padding-left:30px;}
 
 
 


 
  
  • 中国美协章程
  • 中国文联美术艺术中心
    • 综合部
    • 大型活动部
    • 展览部
    • 艺委会工作部
    • 信息资源部
    • 双年展办公室
  • 组织机构
    • 美协机关
      • 办公室
      • 人事处
      • 组联部
      • 外联部
      • 研究部
      • 维权办
    • 中国文联美术艺术中心
      • 综合部
      • 大型活动部
      • 展览部
      • 艺委会工作部
      • 信息资源部
      • 双年展办公室
    • 《美术》杂志社
  • 组织机构
    • 美协机关
      • 办公室
      • 人事处
      • 组联部
      • 外联部
      • 研究部
      • 维权办
    • 中国文联美术艺术中心
      • 综合部
      • 大型活动部
      • 展览部
      • 艺委会工作部
      • 信息资源部
      • 双年展办公室
    • 《美术》杂志社

 

第三种变换形式是:一级菜单会互相影响,也就是一级菜单同时只能打开一个,其他都得处于关闭状态。而且二级菜单也会受到影响,也就是当点击一级菜单的时候,所有的二级菜单都会处于关闭的状态。




  
  jQuery点击展开收缩树形菜单
  
  *{margin: 0;padding: 0}
  body{font-size: 12px;font-family: "宋体","微软雅黑";}
  ul,li{list-style: none;}
  a:link,a:visited{text-decoration: none;color: #fff;}
  .list{width: 210px;border-bottom:solid 1px #316a91;margin:40px auto 0 auto;}
  .list ul li{background-color:#467ca2; border:solid 1px #316a91; border-bottom:0;}
  .list ul li a{padding-left: 10px;color: #fff; font-size:12px; display: block; font-weight:bold; height:36px;line-height: 36px;position: relative;
  }
  .list ul li .inactive{ background:url(images/off.png) no-repeat 184px center;}
  .list ul li .inactives{background:url(images/on.png) no-repeat 184px center;} 
  .list ul li ul{display: none;}
  .list ul li ul li { border-left:0; border-right:0; background-color:#6196bb; border-color:#467ca2;}
  .list ul li ul li ul{display: none;}
  .list ul li ul li a{ padding-left:20px;}
  .list ul li ul li ul li { background-color:#d6e6f1; border-color:#6196bb; }
  .last{ background-color:#d6e6f1; border-color:#6196bb; }
  .list ul li ul li ul li a{ color:#316a91; padding-left:30px;}
  
  
  


  
    
  • 中国美协章程
  • 中国文联美术艺术中心
    • 综合部
    • 大型活动部
    • 展览部
    • 艺委会工作部
    • 信息资源部
    • 双年展办公室
  • 组织机构
    • 美协机关
      • 办公室
      • 人事处
      • 组联部
      • 外联部
      • 研究部
      • 维权办
    • 中国文联美术艺术中心
      • 综合部
      • 大型活动部
      • 展览部
      • 艺委会工作部
      • 信息资源部
      • 双年展办公室
    • 《美术》杂志社
  • 组织机构
    • 美协机关
      • 办公室
      • 人事处
      • 组联部
      • 外联部
      • 研究部
      • 维权办
    • 中国文联美术艺术中心
      • 综合部
      • 大型活动部
      • 展览部
      • 艺委会工作部
      • 信息资源部
      • 双年展办公室
    • 《美术》杂志社

 

这样左侧折叠菜单的三种状态就都已经实现了,是不是特别简单呀。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/91447.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号