子菜单显示了

2019-10-08 15:35 来源:未知

写js代码:
www.308877.com 1

接下去是样式:
www.308877.com 2

#top
{
    height: 36px;
    width: 100%;        
    margin-right: auto;
    margin-left: auto;
    background-color: #006428;

    line-height: 36px;
    text-align: left;
}

#top #top_1
{
    height: 36px;
    width: 1110px;  
    line-height: 36px;
    margin-right: auto;
    margin-left: auto;
}

#top #top_1 ul
{
    margin: 0px;
    padding: 0px;
    list-style-type: none;
}

#top #top_1 li
{
    display: block;
    float: right;
    width: auto;
    line-height: 36px;
    color: #FFFFFF;
    height: 36px;
    font-size: 14px;
}
<div id="top">
            <div id="top_1">
                <ul>                   
                    <li style="position:relative;">
                        <a href="#" id="Menu1" style="text-decoration:none; color:white;">主菜名称</a>
                        <ul id="SubMenu1" style="width: 300px; position: absolute; display: block;">
                            <li><a href="#">子菜名称一</a></li>
                            <li><a href="#">子菜名称二</a> | </li>
                            <li><a href="#">子菜名称三</a> | </li>
                            <li><a href="#">子菜名称四</a> | </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
 <script src="~/Scripts/jquery-2.2.1.js"></script>
 $(function () {
            $("#SubMenu1").hide();

            $("#Menu1").mouseover(function () {                
                showPublish();
            });
        });

        function showPublish() {
            $("#SubMenu1").show();
        }

www.308877.com,Html代码:
www.308877.com 3

Source code:

View Code

View Code

 

www.308877.com 4www.308877.com 5

www.308877.com 6www.308877.com 7

后天有做三个小作用,就是mouse经过主菜单以后,子菜单就长久突显,除非刷新了网页。

 

www.308877.com 8www.308877.com 9

Style source code:

先来看年完毕的成效:
www.308877.com 10

使用jQuery库:

View Code

Source code:

TAG标签:
版权声明:本文由澳门国际银河备用网址发布于www.308877.com,转载请注明出处:子菜单显示了