后台简单界面模板

效果图

html:
<!DOCTYPE html>
<html>
<head>
    <meta charset=utf-8 />
    <title>后台界面模板</title>
    <link rel="stylesheet" type="text/css" href="css/easyui.css">
    <link rel="stylesheet" href="css/index.css">
    <script type="text/javascript"  src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/main.js"></script>
    <!--[if IE]>
    <script src="js/html5shiv.js"></script>
    <![endif]-->
    <script src="js/index.js"></script>

</head>
<body class="easyui-layout">
     <div id="cc"  class="fts-zt-container easyui-layout"> <!--结构-->
         <!--顶部导航栏-->
         <div class="top-nav-header" region="north" split="false" >
             <!--导航条左侧-->
             <div class="nav-left">
                 <div class="left-item-1">
                     <span>
                        <img id="logo-icon" src="images/blocks.gif" />
                        <span>此处放置图标logo</span>
                     </span>
                 </div>
             </div>
             <!--导航条右侧-->
             <div class="nav-right">
                 <div class="right-item-1">
                     <ul id="background-switch">
                         <li class="cur"></li>
                         <li></li>
                         <li></li>
                         <li></li>
                         <li></li>
                     </ul>
                     <div>
                         <span>已登录,欢迎你!小明</span>
                          <span>|</span>
                         <span>切换城市</span>
                          <span>|</span>
                         <span>
                             <span>设置</span>
                            <div class="setting-function">
                                <ul>
                                    li></li>
                                    <li></li>
                                    <li></li>
                                    <li></li>
                                </ul>
                            </div>
                         </span>
                         <span>|</span>
                          <a href="#" id="loginOut">注销</a>
                     </div>
                 </div>
             </div>
         </div>
         <!--中间布局  显示内容-->
         <div region="center" class="center-cnt-side" >
             <div class="easyui-tabs" fit="true" border="false" id="tabs">
                 <div title="&nbsp;首页&nbsp;">
                     系统首页显示
                 </div>
             </div>
         </div>
         <!--左侧菜单-->
         <div region="west"  class="west" title="主菜单">
             <ul class="tree"></ul>
         </div>
         <!--关闭-->
         <div id="tabsMenu" class="easyui-menu" style="width:120px;">
             <div name="close">关闭</div>
             <div name="Other">关闭其他</div>
             <div name="All">关闭所有</div>
         </div>
     </div>
</body>
</html>

自定义样式css

#background-switch li:nth-child(4) {background: #eee5dd;}
#background-switch li:nth-child(5) {background: #0aadee;}
#background-switch li.cur {border-style:inset;}
.setting-function {position: absolute;width: 300px;height: 300px;background: red;}
/*左侧菜单*/
.west{width:15%;padding:10px;height: 300px;}
/*中间内容*/
.center-cnt-side {width: 1140px;height: 165px;}

js:

$(function () {
    $("#background-switch li").click(function () {
        $(".top-nav-header").css("background", $(this).css("background"));
        $("body").css("background", $(this).css("background"));
        $(this).css("background")
        $(this).addClass("cur");
        $(this).sibling().addClass("cur");
    });
});
/**
 * Created by Founder007 on 2018/07/23.
 * 详情请浏览: https://www.cnblogs.com/fly_dragon/p/9186734.html
 */
$(function () {
    //动态菜单数据----一键创建所有数据源
    var treeData = [{
        id: 1,
        text : "菜单",
        state : "closed",
        children : [{
            text : "一级菜单1",
            attributes : {
                url : "test.html"
            }
        }, {
            text : "一级菜单2",
            attributes : {
                url : ""
            }
        }, {
            text : "一级菜单3",
            state : "closed",
            children : [{
                text : "二级菜单1",
                attributes : {
                    url : ""
                }
            }, {
                text : "二级菜单2",
                attributes : {
                    url : ""
                }
            }, {
                text : "二级菜单3",
                state : "closed",
                children : [{
                    text : "三级菜单1",
                    attributes : {
                        url : ""
                    }
                }, {
                    text : "三级菜单2",
                    attributes : {
                        url : ""
                    }
                }, {
                    text : "三级菜单3",
                    attributes : {
                        url : "test.html"
                    }
                }
                ]
            }
            ]
        }]
    },{
        id: 2,
        text : "用户权限管理",
        state : "closed",
        children : [{
            text : "用户信息",
            attributes : {
                url : "test.html"
            }
        }, {
            text : "修改密码",
            attributes : {
                url : ""
            }
        }, {
            text : "设置",
            state : "closed",
            children : [{
                text : "设置1",
                attributes : {
                    url : ""
                }
            }, {
                text : "设置2",
                attributes : {
                    url : ""
                }
            }, {
                text : "设置3",
                state : "closed",
                children : [{
                    text : "系统设置1",
                    attributes : {
                        url : ""
                    }
                }, {
                    text : "系统设置2",
                    attributes : {
                        url : ""
                    }
                }, {
                    text : "系统设置3",
                    attributes : {
                        url : "test.html"
                    }
                }
                ]
            }
            ]
        }
        ]
    }];


    //实例化树形菜单---直接把所有数据源赋值给实例化tree
    $("div.west .tree").tree({
        data : treeData,
        lines : true,
        onClick : function (node) {
            if (node.attributes) {
                Open(node.text, node.attributes.url);
            }
        }
    });


    //在右边center区域打开菜单,新增tab
    function Open(text, url) {
        var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';

        if ($("#tabs").tabs('exists', text)) {
            $('#tabs').tabs('select', text);
        } else {
            $('#tabs').tabs('add', {
                title : text,
                closable : true,
                content : content
            });
        }
    }

    //绑定tabs的右键菜单
    $("#tabs").tabs({
        onContextMenu : function (e, title) {
            e.preventDefault();
            $('#tabsMenu').menu('show', {
                left : e.pageX,
                top : e.pageY
            }).data("tabTitle", title);
        }
    });

    //实例化menu的onClick事件
    $("#tabsMenu").menu({
        onClick : function (item) {
            CloseTab(this, item.name);
        }
    });

    //几个关闭事件的实现
    function CloseTab(menu, type) {
        var curTabTitle = $(menu).data("tabTitle");
        var tabs = $("#tabs");

        if (type === "close") {
            tabs.tabs("close", curTabTitle);
            return;
        }

        var allTabs = tabs.tabs("tabs");
        var closeTabsTitle = [];

        $.each(allTabs, function () {
            var opt = $(this).panel("options");
            if (opt.closable && opt.title != curTabTitle && type === "Other") {
                closeTabsTitle.push(opt.title);
            } else if (opt.closable && type === "All") {
                closeTabsTitle.push(opt.title);
            }
        });

        for (var i = 0; i < closeTabsTitle.length; i++) {
            tabs.tabs("close", closeTabsTitle[i]);
        }
    }
});

目录结构

猜你喜欢

转载自blog.csdn.net/qq_31935419/article/details/81224593
今日推荐