DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> JS實現仿京東淘寶豎排二級導航
JS實現仿京東淘寶豎排二級導航
編輯:關於JavaScript     

代碼很簡單,就不多廢話了,直接奉上代碼:

復制代碼 代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script type="text/javascript">
    function hoversee(){
    var list = document.getElementById('nav');
    var zu = list.getElementsByTagName("li");
    for(var i=0;i<9;i++)
    {
        zu[i].onmouseover = function(){
            this.getElementsByTagName('dl')[0].style.display = "block";
        }
        zu[i].onmouseout = function(){
            this.getElementsByTagName('dl')[0].style.display = "none";
        }
    }
    }
    window.onload = hoversee;
</script>
<style>
    *{
        font-family:Microsoft YaHei;
        margin:0;
        padding:0;
    }
    body{width:100%;}
    ul{list-style: none;}
    a{text-decoration: none;}
    #header{
        height:50px;
        line-height:50px;
        background:#455A6E;
    }
    #header h2,#header h3{
        font-weight:500;
    }
    #header h2{
        color:#fff;
        font-size:18px;
        width:180px;
        text-align: center;
        background:#0D2E49;
    }
    #header h3{color:#fff;font-size:16px;}
    .mycenter{
        width:900px;
        margin:0 auto;
    }
    #header div.mycenter{
        /*相對定位*/
        position:relative;
    }
    #nav {
        width:180px;
        background:rgba(0, 102, 173, 0.5);
        z-index:999;
    }
    #nav li{
        height:40px;
        padding-left:40px;
        line-height: 40px;
        position:relative;
    }
    #nav h3{height:40px;}
    #nav li dl{
        position:relative;
        left:140px;
        top:-40px;
        width:150px;
        background:#fff;
        display:none;
        padding:8px 10px;
    }
    #nav dt{
        width:150px;
        line-height: 30px;
        height:30px;
        background:#36C1AF;
        color:#fff;
        text-align: center;
    }
    #nav dd a{
        display:block;
        height:30px;
        width:150px;
        font-size:14px;
        color:#858585;
    }
    #nav dd a:hover{
        text-decoration: underline;
    }
    #content{
        background:#E95200;
        height:500px;
    }
</style>
</head>
<body>
    <div id="header">
        <div class="mycenter">
            <h2>後台管理菜單</h2>
            <ul id="nav">
                <li>
                    <h3>帳號管理</h3>
                    <dl>
                        <dt>帳號管理</dt>
                        <dd>
                            <a href="#">修改密碼</a>
                            <a href="#">修改用戶名</a>
                            <a href="#">設置密保問題</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>首頁管理</h3>
                    <dl>
                        <dt>首頁管理</dt>
                        <dd>
                            <a href="#">輪轉照片設置</a>
                            <a href="#">產品展示照片設置</a>
                            <a href="#">底部信息修改</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>產品管理</h3>
                    <dl>
                        <dt>產品管理</dt>
                        <dd>
                            <a href="#">增加新產品</a>
                            <a href="#">管理全部產品</a>
                            <a href="#">類別管理</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>新聞管理</h3>
                    <dl>
                        <dt>新聞管理</dt>
                        <dd>
                            <a href="#">發布新聞</a>
                            <a href="#">全部新聞管理</a>
                            <a href="#">增加系列</a>
                            <a href="#">新聞系列管理</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>反饋管理</h3>
                    <dl>
                        <dt>反饋管理</dt>
                        <dd>
                            <a href="#">管理所有反饋</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>企業信息管理</h3>
                    <dl>
                        <dt>企業信息管理</dt>
                        <dd>
                            <a href="#">企業簡介</a>
                            <a href="#">企業聯系方式設置</a>
                            <a href="#">人才招聘管理</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>權限管理</h3>
                    <dl>
                        <dt>權限管理</dt>
                        <dd>
                            <a href="#">添加新管理員</a>
                            <a href="#">查看所有賬號權限</a>
                            <a href="#">查看申訴</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>功能管理</h3>
                    <dl>
                        <dt>功能管理</dt>
                        <dd>
                            <a href="#">一級功能設置</a>
                        </dd>
                    </dl>
                </li>
                <li>
                    <h3>權限查看與申請</h3>
                    <dl>
                        <dt>權限查看與申請</dt>
                        <dd>
                            <a href="#">查看自己的權限</a>
                            <a href="#">申請權限</a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <div id="content">
    </div>
    <div id="footer">
    </div>
</body>
</html>

小伙伴們根據自己的需求,將調用代碼加進去就可以了,自由發揮吧。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved