您好我用子菜单制作了子菜单菜单。但它正在下降而不是向右侧。我是CSS的新手。你可以看到demo Here
请检查并可以获得一些帮助,将子子菜单对齐到子菜单的右侧。例如:对齐' DB'并且' OT' INS'右侧
注意:我需要显示' DB'并且' OT'只有悬停在菜单“ECC'”现在它正在为所有其他人展示。
.menuborder {
border-style: solid;
border-width: 1px;
border-color: #ffffff #0000ff #ffffff #ffffff;
}
.mainmenu {
height: 0px;
}
.mainmenu ul#nav {
list-style: outside none none;
margin: 0;
padding: 0;
text-align: left;
}
.mainmenu ul#nav li {
display: inline-block;
}
.mainmenu ul#nav li a {
color: #266696;
display: block;
margin: 0 -2px;
padding: 2px 15px;
text-transform: uppercase;
}
.mainmenu ul#nav li:hover>a {
background: #11c3f1 none repeat scroll 0 0;
}
/*=================
DropDown Menu
===================*/
#nav>li {
position: relative;
}
#nav>li:hover ul {
opacity: 1;
z-index: 9999;
top: 100%;
visibility: visible;
}
#nav>li ul {
background: #fff none repeat scroll 0 0;
opacity: 0;
left: -2px;
list-style: outside none none;
margin: 0;
padding: 0;
position: absolute;
text-align: left;
transition: all 0.5s ease 0s;
width: 204px;
padding-left: 2px;
z-index: -99999;
top: 150%;
visibility: hidden
}
#nav>li ul li {
display: block;
width: 200px;
}
.mainmenu ul#nav li ul li a:hover {
color: #fff;
border-radius: 0 0 80px 0;
border-left: 4px solid #000;
padding-left: 10px;
}
.mainmenu ul#nav li ul li a {
border-bottom: 1px solid #ddd;
color: #000;
padding: 10px 10px;
}

<div class="col-md-5 col-lg-5">
<div class="mainmenu nav">
<ul id="nav">
<li class="menuborder"><a href="#">Ins</a>
<ul>
<li><a href="#">Ecc</a>
<ul>
<li><a href="#">DB</a></li>
<li><a href="#">Ot</a></li>
</ul>
</li>
<li><a href="#">Edu</a></li>
<li><a href="#">Emp</a></li>
<li><a href="#">Med</a></li>
<li><a href="#">Med</a></li>
<li><a href="#">Pr</a></li>
<li><a href="#">Re</a></li>
<li><a href="#">Soc</a></li>
</ul>
</li>
<li class="menuborder"><a href="#">Assoc</a>
<ul>
<li><a href="#">Pi</a></li>
<li><a href="#">Co</a></li>
<li><a href="#">Com</a></li>
<li><a href="#">Fo</a></li>
<li><a href="#">Mo</a></li>
<li><a href="#">Org</a></li>
<li><a href="#">K</a></li>
</ul>
</li>
<li class="menuborder"><a href="#">Cong</a>
<ul>
<li><a href="#">Rel</a></li>
<li><a href="#">Wel</a></li>
</ul>
</li>
<li></li>
</ul>
</div>
</div>
&#13;
答案 0 :(得分:2)
您可以使用Date(timeStamp)
进行设置,请查看以下更新的代码段:
position
.menuborder {
border-style: solid;
border-width: 1px;
border-color: #ffffff #0000ff #ffffff #ffffff;
}
.mainmenu {
height: 0px;
}
.mainmenu ul#nav {
list-style: outside none none;
margin: 0;
padding: 0;
text-align: left;
}
.mainmenu ul#nav li {
display: inline-block;
position: relative;
}
.mainmenu ul#nav li a {
color: #266696;
display: block;
margin: 0 -2px;
padding: 2px 15px;
text-transform: uppercase;
}
.mainmenu ul#nav li:hover>a {
background: #11c3f1 none repeat scroll 0 0;
}
/*=================
DropDown Menu
===================*/
#nav>li {
position: relative;
}
#nav>li:hover ul {
opacity: 1;
z-index: 9999;
top: 100%;
visibility: visible;
}
#nav>li ul {
background: #fff none repeat scroll 0 0;
opacity: 0;
left: -2px;
list-style: outside none none;
margin: 0;
padding: 0;
position: absolute;
text-align: left;
transition: all 0.5s ease 0s;
width: 204px;
padding-left: 2px;
z-index: -99999;
top: 150%;
visibility: hidden
}
#nav>li ul li {
display: block;
width: 200px;
}
.mainmenu ul#nav li ul li a:hover {
color: #fff;
border-radius: 0 0 80px 0;
border-left: 4px solid #000;
padding-left: 10px;
}
.mainmenu ul#nav li ul li a {
border-bottom: 1px solid #ddd;
color: #000;
padding: 10px 10px;
}
.mainmenu ul#nav li ul li.sub-sub-menu ul {
position: absolute;
left: 100%;
top: 0px;
display: none;
}
.mainmenu ul#nav li ul li.sub-sub-menu:hover ul {
display: block;
}
}
答案 1 :(得分:1)
您可以通过在演示结束时添加两组规则并修改下拉菜单的第一个选择器来快速完成工作:
/*=================
DropDown Menu
===================*/
#nav li {
position: relative;
}
[...]
#nav li ul ul {
left: 100%;
}
#nav li:hover ul ul {
top: 0;
}
您可以在此处查看:https://jsfiddle.net/1o795Ly8/
但我建议改变很多其他的东西,比如:
否则,维护和更新菜单会遇到很多麻烦。