layUI实现三级导航菜单效果
lickybay 人气:1本文实例为大家分享了layUI实现三级导航菜单展示的具体代码,供大家参考,具体内容如下
废话不多说,直接上代码:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title>layout 后台大布局 - Layui</title> <link rel="stylesheet" href="../css/layui.css" rel="external nofollow" > <script src="../layui.js"></script> <style> .layui-layout-left{position: absolute !important; left: 0px; top: 0;} /*layui child nav*/ .layui-nav-child{display: none; position: absolute; left: 0; top: 65px; min-width: 100%; line-height: 36px; padding: 5px 0; box-shadow: 0 2px 4px rgba(0,0,0,.12); border: 1px solid #d2d2d2; background-color: #fff; z-index: 100; border-radius: 2px; white-space: nowrap;} .layui-nav .layui-nav-child a{color: white;} .layui-nav .layui-nav-child a:hover{background-color:deepskyblue; color: white;} .layui-nav-child dd{position: relative;} .layui-nav-child dd.layui-this{background-color: transparent; color: white;} .layui-nav .layui-nav-child dd.layui-this a{background-color: transparent; color: white;} .layui-nav-child dd.layui-this:after{display: none;} /*layui third level nav*/ .layui-nav-third-child{display: none; position: absolute; left: 105px;top:25px;min-width: 100%; line-height: 36px; padding: 5px 0; box-shadow: 0 2px 4px rgba(0,0,0,.12); border: 1px solid #d2d2d2; background-color: #fff; z-index: 100; border-radius: 2px; white-space: nowrap;} .layui-nav .layui-nav-third-child a{color: white;} .layui-nav .layui-nav-third-child a:hover{background-color:deepskyblue; color: white;} .layui-nav-third-child li{position: relative;} .layui-nav-third-child li{background-color: transparent; color: white;} .layui-nav .layui-nav-third-child li.layui-this a{background-color: transparent; color: white;} .layui-nav-third-child li:after{display: none;} </style> </head> <body class="layui-layout-body "> <div class="layui-layout layui-layout-admin layui-bg-blue"> <div class="layui-header layui-bg-blue"> <div style="margin-left: 20px"> <b style="font-size: 35px">船信保密安全综合管控平台</b><br> <b>CSIT integrated Control System of Confidentiality and Security</b> </div> <!-- 头部区域(可配合layui已有的水平导航) --> <ul class="layui-nav layui-layout-right"> <li class="layui-nav-item"> <a href="javascript:;" > <img src="http://t.cn/RCzsdCq" class="layui-nav-img"> 贤心 </a> <dl class="layui-nav-child"> <dd><a href="#" >基本资料</a><https://img.qb5200.com/download-x/dd> <dd><a href="#" >安全设置</a><https://img.qb5200.com/download-x/dd> <https://img.qb5200.com/download-x/dl> </li> <li class="layui-nav-item"><a href="">退了</a></li> </ul> </div> <div class="layui-header layui-bg-blue"> <!-- 头部区域(可配合layui已有的水平导航) --> <ul class="layui-nav layui-layout-left"> <li class="layui-nav-item"><a href="#" >控制台</a></li> <li class="layui-nav-item"><a href="#" >商品管理</a></li> <li class="layui-nav-item"><a href="#" >用户</a></li> <li class="layui-nav-item"> <a href="javascript:;" >其它系统</a> <dl class="layui-nav-child layui-bg-blue"> <dd><a href="">邮件管理</a><https://img.qb5200.com/download-x/dd> <dd><a href="">消息管理</a><https://img.qb5200.com/download-x/dd> <dd><a href="">授权管理</a><https://img.qb5200.com/download-x/dd> <dd> <a href="javascript:;" class="third-class">其它系统2</a> <ol class="layui-nav-third-child layui-bg-blue"> <li><a href="">邮件管理2</a></li> <li><a href="">消息管理2</a></li> <li><a href="">授权管理2</a></li> </ol> <https://img.qb5200.com/download-x/dd> <dd> <a href="javascript:;" class="third-class">其它系统3</a> <ol class="layui-nav-third-child layui-bg-blue"> <li><a href="">邮件管理3</a></li> <li><a href="">消息管理3</a></li> <li><a href="">授权管理3</a></li> </ol> <https://img.qb5200.com/download-x/dd> <https://img.qb5200.com/download-x/dl> </li> </ul> </div> <div class="layui-body"> <!-- 内容主体区域 --> <div style="padding: 15px;">内容主体区域</div> </div> <div class="layui-footer"> <!-- 底部固定区域 --> © layui.com - 底部固定区域 </div> </div> <script> //JavaScript代码区域 layui.use(['element','jquery'], function(){ var element = layui.element,$=layui.jquery; $(".layui-nav-third-child").hide(); $(".third-class").on('click',function () { $(".layui-nav-third-child").hide(); $(this).next().show(); }); }); </script> </body> </html>
style中是重写了layui的全局样式,为了调节需要的颜色可忽略,思路是依照layui样式的显现关系,通过控制third-child的显示隐藏达到三级菜单的目的。需要引用小箭头的只需引入layui-tab-more,建议去看看他的实现方式,作为一个javaer我是没想到小三角还能如此简单的实现。
加载全部内容