layUI 三级导航菜单的实现

废话不多说,直接上代码:


<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layuititle>
    <link rel="stylesheet" href="../css/layui.css">
    <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 Securityb>

         div>
        

        <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>dd>
                    <dd><a href="#">安全设置a>dd>
                dl>
            li>
            <li class="layui-nav-item"><a href="">退了a>li>
        ul>
    div>
    <div class="layui-header layui-bg-blue">
        
        <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>dd>
                    <dd><a href="">消息管理a>dd>
                    <dd><a href="">授权管理a>dd>
                    <dd>
                        <a href="javascript:;" class="third-class">其它系统2a>
                        <ol class="layui-nav-third-child layui-bg-blue">
                            <li><a href="">邮件管理2a>li>
                            <li><a href="">消息管理2a>li>
                            <li><a href="">授权管理2a>li>
                        ol>
                    dd>
                    <dd>
                        <a href="javascript:;" class="third-class">其它系统3a>
                        <ol class="layui-nav-third-child layui-bg-blue">
                            <li><a href="">邮件管理3a>li>
                            <li><a href="">消息管理3a>li>
                            <li><a href="">授权管理3a>li>
                        ol>
                    dd>

                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我是没想到小三角还能如此简单的实现。

你可能感兴趣的:(工作记录)