简体   繁体   English

CSS下拉菜单,添加另一个<ul>

[英]CSS drop down menu, Adding another <ul>

I have a drop down menu made with css and at the moment it has 5 li that are visable. 我有一个使用CSS制作的下拉菜单,目前有5 li可见。 When you hover over one of the li it highlights and then the drop down effect happens and the next ul shows underneath. 当您将鼠标悬停在li上时,它会突出显示,然后会出现下拉效果,而下一个ul将显示在下面。 So basically you have a first set of options to choose from and then when you hover over the first set of options you get a second set of options. 因此,基本上,您有第一组选项可供选择,然后将鼠标悬停在第一组选项上时,便得到第二组选项。 What I would like to do is make a third set of options appear when you hover over the second set of options and make this third set of options appear to the right of the second options. 我想做的是将鼠标悬停在第二组选项上时显示第三组选项,并使第三组选项出现在第二组选项的右侧。

a link to exactly what i would like to do: http://cssmenumaker.com/menu/opera-drop-down-menu 精确链接到我想做的事情: http : //cssmenumaker.com/menu/opera-drop-down-menu

Here is my html. 这是我的HTML。 Note the descriptions of the li are not final i will change what i want the links to say later. 请注意,对li的描述不是最终的,我将更改我希望链接稍后说的内容。

<li><a href="#">Home</a>
<ul class="subforums">
<li><a href="#">Elite's</a></li>
<li><a href="#">Newbs</a></li>
<li><a href="#">Subscribers</a></li>
</ul>
</li>
<li><a href="#">Samples</a>
<ul class="subsites">
<li><a href="#">Architecture</a></li>
<li><a href="#">Furniture</a></li>
</ul>
</li>
<li><a href="#">Workshop</a>
<ul class="subcontactus">
<li><a href="#">By Phone</a></li>
<li><a href="#">By e-mail</a></li>
<li><a href="#">By Text</a></li>
</ul>
</li>
<li><a href="#">About</a>
<ul class="subabout">
<li><a href="#">The Team</a></li>
<li><a href="#">Our Story</a></li>
<li><a href="#">Our Goal</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a>
<ul class="subsignup">
<li><a href="#">Find Out More</a></li>
<li><a href="#">Costs</a></li>
<li><a href="#">Paying Methods</a></li>
</ul>
</li>
</ul>

` note: there is a ul opening tag before all of the html that i have just posted but it wouldn't let me have it on here for some reason. `注意:在我刚刚发布的所有html之前都有一个ul开头标签,但是由于某种原因,它不会让我在这里看到它。

and the css: 和CSS:

navmenu is the id for the opening ul of the whole drop down menu `#navmenu, #navmenu ul{ list-style-type: none; navmenu是整个下拉菜单`#navmenu,#navmenu ul {list-style-type:none; } }

#navmenu li{
width: 125px;
text-align: center;
position: relative;
float: left;
margin-right: 4px;
}
#navmenu a{
text-decoration: none;
display: block;
width: 125px;
height: 25px;
line-height: 25px;
background-color: #00cff0;
border: 1px solid #ccc;
border-radius: 5px;
color: white;
}
#navmenu li:hover > a{
background-color: #00d3f5;
}
#navmenu li:hover a:hover{
font-size: 105%;
}
#navmenu ul{
display: block;
position:absolute;
top: 26px;
left: 0;
visibility: hidden;
margin: 0;
padding: 0;
}
#navmenu li:hover ul{
visibility: visible;
}
#navmenu{
margin: auto;
width: 700px;
}`#navmenu, #navmenu ul{
list-style-type: none;
}
#navmenu li{
width: 125px;
text-align: center;
position: relative;
float: left;
margin-right: 4px;
}
#navmenu a{
text-decoration: none;
display: block;
width: 125px;
height: 25px;
line-height: 25px;
background-color: #00cff0;
border: 1px solid #ccc;
border-radius: 5px;
color: white;
}
#navmenu li:hover > a{
background-color: #00d3f5;
}
#navmenu li:hover a:hover{
font-size: 105%;
}
#navmenu ul{
display: block;
position:absolute;
top: 26px;
left: 0;
visibility: hidden;
margin: 0;
padding: 0;
}
#navmenu li:hover ul{
visibility: visible;
}
#navmenu{
margin: auto;
width: 700px;
}

I hope you can understand this and help me out. 希望您能理解并帮助我。 I have tried to be as clear as possible thankyou for reading. 我已尽力使您的阅读尽可能清楚。 :) :)

Working Demo Here 在这里工作演示

you need to add these calsses to your css: 您需要将这些cals添加到您的CSS中:

ul#navmenu li ul li ul {
    list-style-type: none;
    position: absolute;
    display: none;
    left: 0;
    margin: -26px 0 0 127px;
    padding: 0;
}
ul#navmenu li ul li:hover ul {
    display: block;
}

you can see your code on JSFiddle 您可以在JSFiddle上看到您的代码

If means anything to you I made this FIDDLE couple of days ago for similar question 如果对您没有任何意义,我几天前就做了类似问题的FIDDLE

<div id="menu">
  <ul>
    <li><a href="index.php">Home</a></li>
    <li><a href="#">Link 2</a>
      <ul class="submenu">
        <li><a href="#">Link 2.1</a></li>
        <li><a href="#">Link 2.2</a></li>
        <li><a href="#">Link 2.3</a></li>
        <li><a href="#">Link 2.4</a></li>
        <li><a href="#">Link 2.5</a></li>
      </ul>
    </li>
    <li><a href="#">Link 3</a>
      <ul class="submenu">
        <li><a href="#">Link 3.1</a></li>
        <li><a href="#">Link 3.2</a></li>
        <li><a href="#">Link 3.3</a></li>
        <li><a href="#">Link 3.4</a></li>
        <li><a href="#">Link 3.5</a>
          <ul class="sub-submenu">
            <li><a href="#">Link 3.5.1</a></li>
            <li><a href="#">Link 3.5.2</a></li>
            <li><a href="#">Link 3.5.3</a></li>
            <li><a href="#">Link 3.5.4</a></li>
            <li><a href="#">Link 3.5.5</a></li>
          </ul> 
        </li>
      </ul>
    </li>
    <li><a href="#">Link 4</a></li>
    <li><a href="#">Link 5</a></li>
  </ul>
</div>

#menu {
  background: #333;
  width: 960px;
  margin: 0 auto;
  height: 30px;
}
#menu ul {
  list-style: none;
}
#menu ul li {
  float: left;
}
#menu ul li a {
  display: block;
  height: 25px;
  padding: 5px 10px 0 10px;
  font-family: Verdana;
  font-size: 16px;
  letter-spacing: 1px;
  text-decoration: none;
  color: #fff;
  text-shadow: 1px 1px 0 #252525;
  transition: all 0.2s linear;
}
#menu ul li a:hover {
  background: #555;
  color: #00aeff;
}
#menu ul li .submenu {
  background: #333;
  position: absolute;
  display: none;
  top: 46px;
  margin-left: 0;
  padding: 0;
  width: 150px;    
}
#menu ul li:hover .submenu {
  display: block;
}
#menu ul li .submenu li {
  margin-bottom: 5px;
  width: 100%;
}
#menu ul li .submenu li .sub-submenu {
  background: #333;
  position: absolute;
  display: none;
  left: 0;
  margin: -30px 0 0 150px;
  padding: 0;
  width: 150px;    
}
#menu ul li .submenu li:hover .sub-submenu {
  display: block;
}

I think I have what you are after. 我想我有你要的。

3 level menu. 3级菜单。

Codepen Example Codepen示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM