如何使用css文件在主菜单中进行子菜单 [英] How to sub menu in the main menu using the css file

查看:65
本文介绍了如何使用css文件在主菜单中进行子菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我将粘贴Css代码和asp代码。请在此代码中添加子菜单。

Here i will paste the Css code and asp code. pls add the submenu in this code.

* { padding: 0; margin: 0; }

body {
 font-family:Times New Roman ;
 font-size: 13px;
 border-color :Black ;
}
#wrapper {
 margin: 0 auto;
 width: 924px;
}
#header {
 width: 922px;
 color: #333;
 padding: 0px;
 border: 1px solid #ccc;
 height: 56px;
 margin: 0px 0px 0px 0px;
 background: #DAC8BF;
}
img
{
    margin : 0;
    height:57px;
    width:923px;

}
h1
{
    font-size :13px;
    text-align :center ;
    padding :20px;
}
#navigation
{



}
#tabs
{ width: 902px;
 color: #444;
 padding: 10px;
 border: 1px solid #ccc;
 margin: 0px 0px 0px 0px;
    float:left;
    background:#D4DAE7;
    font-size:93%;
    line-height:normal;

}
#tabs ul {
    margin:0;
    padding:10px 10px 0 50px;
    list-style:none;
    height:30px;
    }

#tabs li
{
    position:relative ;
    display:inline;
    margin:0;
    padding:0;
    }

#tabs a {
    float:left;
    background:url("img/tableft.gif") no-repeat left top;
    margin:0;
    padding:0 0 0 4px;
    text-decoration:none;
    }

#tabs a span {
    float:left;
    display:block;
    background:url("img/tabright.gif") no-repeat right top;
    padding:5px 15px 4px 6px;
    color:#999;

    }
    #tabs a:hover span
    {
    color:#ECB546;
    }

#tabs a:hover {
    background-position:0% -42px;
    }

#tabs a:hover span {
    background-position:100% -42px;
    }
#cen
{
    width:923px;
    height:480px;

}
#sidebar
{
float:left ;
width:202px;
color:black;
border: 1px solid #ccc;
border-right-style:dashed #ccc;
background-color:#F3F2ED;
height:417px;
}

#content
{
float :right ;
width: 697px;
color: black;
border: 1px solid #ccc;
background:white;
margin: 0px 0px 0px 0px;
padding: 10px;
height:397px;
}

#footer {
 width: 902px;
 border: 1px solid #ccc;
 background-color:#F3F2ED;
 margin: 0px 0px 0px 0px;
 padding: 10px;
 text-align:center;
 color :Black ;
}





ASP:代码





ASP:Code

<asp:Content ID="Content1" runat="server"

    contentplaceholderid="ContentPlaceHolder4">

          <li><a href="#"><span>File</span></a></li>
          <li><a href="loan_entry.aspx"><span>Masters</span></a></li>
          <li><a href="#"><span>Reports</span></a></li>
          <li><a href="#"><span>Help</span></a></li>
          <li><a href="#"><span>Contact us</span></a></li>

</asp:Content>

推荐答案

嘿那里,





我想,这里是每一个你需要:



http ://css-tricks.com/targetting-menu-elements-submenus-navigation-bar/ [ ^ ]



希望它有所帮助。



Azee ...
Hey there,


I think, here is everything you need:

http://css-tricks.com/targetting-menu-elements-submenus-navigation-bar/[^]

Hope it helps.

Azee...


* MENU */

#nav {
 background: #e5e5e5;
 float: left;
 margin: 0; padding: 0;
 border: 1px solid white;
 border-bottom: none;
}

#nav li a, #nav li {
 float: left;
}

#nav li {
 list-style: none;
 position: relative;
}

#nav li a {
 padding: 1em 2em;
 text-decoration: none;
 color: white;
 background: #292929;
 background: -moz-linear-gradient(top, black, #3c3c3c 1px, #292929 25px);
 background: -webkit-gradient(linear, left top, left 25, from(black), color-stop(4%, #3c3c3c), to(#292929));
 border-right: 1px solid #3c3c3c;
 border-left: 1px solid #292929;
 border-bottom: 1px solid #232323;
 border-top: 1px solid #545454;
}

#nav li a:hover {
 background: #2a0d65;
 background: -moz-linear-gradient(top, #11032e, #2a0d65);
 background: -webkit-gradient(linear, left top, left bottom, from(#11032e), to(#2a0d65));
}


/* Submenu */

.hasChildren {
    position: absolute;
    width: 5px; height: 5px;
    background: black;
    right : 0;
    bottom: 0;
}

#nav li ul {
 display: none;
 position: absolute;
 left: 0;
 top: 100%;
 padding: 0; margin: 0;
}

#nav li:hover > ul {
 display: block;
}

#nav li ul li, #nav li ul li a {
 float: none;
}

#nav li ul li {
 _display: inline; /* for IE6 */
}

#nav li ul li a {
 width: 150px;
 display: block;
}

/* SUBSUB Menu */

#nav li ul li ul {
 display: none;
}

#nav li ul li:hover ul {
 left: 100%;
 top: 0;
}


#nav li ul



<ul id="nav">
	<li><a href="#">Item 1</a></li>
	<li><a href="#">Item 2</a>
            <ul>
                <li><a href="#">Sub 1</a></li>
                <li><a href="#">Sub 2</a></li>
                <li><a href="#">Sub 3</a></li>
            </ul>
        </li>	
	<li><a href="#">Item 3</a></li>
</ul>


见:

See this:
<link href="/css_menu.css" type="text/css" rel="Stylesheet"/>
                <div id="menuwrapper">
                        <ul>
                            <li><a href="http://xxx.com/contact.php"">Contact</a></li>
                            <li><a href="http://xxx.com/product_template_list.php">Produc Lines</a>
//SUBMENU OF PRODUCT LINE
                                <ul>
                                    <li><a href="#">Product 1</a></li>
                                    <li><a href="#">Product 2</a></li>
                                    <li><a href="#">Product 3</a></li>
                                </ul>
                            </li>
                            
                            <li ><a href="http://xxx.com">Home</a></li>
                         </ul>
                    </div>





这是s的css代码ub菜单:



And this is css code for sub menu:

/**** SECOND LEVEL MENU ****/
/* We make the position to absolute for flyout menu and hidden the ul until the user hover the parent li item */
#menuwrapper ul li ul{
    position:absolute;
    display:none;
}

/* When user has hovered the li item, we show the ul list by applying display:block, note: 25px is the menu height.  */
#menuwrapper ul li:hover ul{
    left:0;
    top:25px;
    display:block;
}

/* As the parent li has float:left property, we overwrite for the submenu (level 2) to float none (normal position)  */
#menuwrapper ul li ul li{
    float:none;
    width:150px;
    background-color:#cae25a;
}

/* We change the background color for the level 2 submenu when hovering the menu */
#menuwrapper ul li:hover ul li:hover{
    background-color:#b1b536;
}

/* We style the color of level 2 links */
#menuwrapper ul li ul li a{
    color:#454444;
    display:inline-block;
    width:120px;
}







Hope it helps!




Hope it helps!


这篇关于如何使用css文件在主菜单中进行子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆