我有一个菜单下拉列表,使用css和html完成。现在,我希望在现有子菜单上有一个子菜单的扩展名,当我悬停“审计报告”时,它应该垂直显示另一个子菜单。我怎样才能实现呢?这是我在css和html中的现有代码
CSS
.menuPanel
{
width: auto;
height: 32px;
top: 5px;
border-bottom: 1px solid #808080;
background-color: #4f4545;
}
.nav,.nav ul
{
list-style: none;
margin:0;
padding:0;
}
.nav {
position:relative;
left: 2px;
height: auto;
}
.nav ul
{
height:0;
left:0;
overflow: hidden;
position:absolute;
}
.nav li
{
float:left;
position:relative;
}
.nav li a
{
-moz-transition:1.0s;
-o-transition:1.0s;
-webkit-transition:1.0s;
transition:1.0s;
background-color: #4f4545;
display: block;
color:#FFF;
text-decoration:none;
font-size:12px;
line-height:32px;
padding:0px 30px;
}
.nav li:hover > a
{
background: #8CCA33;
border-color: #6E67A6;
color:#fff;
}
.nav li:hover ul.subs
{
height:auto;
width: 250px;
z-index: 10;
}
.nav ul li
{
-moz-transition:0.3s;
-o-transition:0.3s;
-webkit-transition:0.3s;
opacity:0;
transition:0.3s;
width:100%;
}
.nav li:hover ul li
{
opacity:1;
-moz-transition-delay:0.2s;
-o-transition-delay:0.2s;
-webkit-transition-delay:0.2s;
transition-delay:0.2s;
}
.nav ul li a
{
background: #4f4545;
border: 1px solid #808080;
color:#fff;
line-height:1px;
-moz-transition:1.5s;
-o-transition:1.5s;
-webkit-transition:1.5s;
transition:1.5s;
}
.nav li:hover ul li a
{
line-height:32px;
}
.nav ul li a:hover
{
background:#8CCA33;
}
aspx页面设计
<ul class="nav">
<li><a href="Home.aspx">HOME</a></li>
<li><a href="#">FILE ▾</a>
<ul class="subs">
<li><a href="TenantFileList.aspx">Tenants List</a></li>
<li><a href="UserFileList.aspx">Users List</a></li>
<li><a href="TenantRental.aspx">Tenant Rental</a></li>
</ul>
</li>
<li><a href="#">REPORTS ▾</a>
<ul class="subs">
<li><a href="#">Audit Reports</a>
<ul>
<li><a href='#'>Sub Product</a></li>
<li><a href='#'>Sub Product</a></li>
</ul>
</li>
<li><a href="#">Leasing Reports</a></li>
<li><a href="#">Marketing Reports</a></li>
</ul>
</li>
<li id="admin" visible="true" runat="server"><a href="#">ADMIN ▾</a>
<ul class="subs">
<li><a href="SystemLogs.aspx">System Logs</a></li>
<li><a href="UserRequest.aspx">User Request</a></li>
</ul>
</li>
<li><a href="Login.aspx">LOG-OUT</a>
</li>
</ul>
</div>
答案 0 :(得分:3)
您必须为整个块执行.nav .subs ul
的新CSS样式,或为块的单个元素执行.nav .subs ul li
示例:
.nav .subs li ul
{
max-height: 0;
-moz-transition:1.5s;
-o-transition:1.5s;
-webkit-transition:1.5s;
transition:1.5s;
}
.nav .subs li:hover > ul
{
max-height: 300px;
height: auto;
}
.nav .subs li ul
{
left: 250px;
top: 0;
overflow: hidden;
}
这只是显示新的块,如果你将鼠标悬停在一个子菜单项上,现在你只需要设置样式并将其放置在你想要的地方
JSFiddle上的示例: http://jsfiddle.net/4sym7ry0/3/
答案 1 :(得分:2)
在ListItem中执行嵌套的Unorderlist和orderedlist
查看此更多信息: http://www.thecodingguys.net/blog/css3-create-a-vertical-menu-with-sub-menu