0

当前的html

<html>
<head>
    <link rel='stylesheet' type='text/css' href='css/styles.css' />
    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'>    </script>
</head>
<body>
<div id='cssmenu'>
<ul>
   <li><a href='index.html'><span>Home</span></a></li>
   <li><a href='team'><span>Team</span></a>
       <ul class= "sub1">
            <li><a href='team'><span>Team</span></a>
            <li><a href='team'><span>Team2</span></a>
       </ul>
   </li>
   <li><a href='sponsors'><span>Sponsors</span></a></li>
   <li><a href='first'><span>First</span></a></li>
   <li><a href='contact-us'><span>Contact Us</span></a></li>
   <li class='last'><a href='handouts'><span>Handouts</span></a></li>
</ul>
</div>
</body>
</html>

的CSS

#cssmenu ul {
  list-style-type: none;
  position: relative;
  display: block;
  height: 33px;
  font-size: 12px;
  background: url(../images/bg.png) repeat-x top left;
  font-family: Verdana, Helvetica, Arial, sans-serif;
  border: 1px solid #000;
  margin: 0;
  padding: 0;
  width: auto;
}
 #cssmenu li {
  display: block;
  float: left;
  margin: 0;
  padding: 0;
}
#cssmenu li a {
  float: left;
  color: #A79787;
  text-decoration: none;
  height: 24px;
  padding: 9px 15px 0;
 font-weight: normal;
}
#cssmenu li a:hover,
#cssmenu .active {
  color: #fff;
  background: url(../images/bg.png) repeat-x top left;
  text-decoration: none;
}
#cssmenu .active a {
  color: #fff;
  font-weight: 700;
}
#cssmenu ul {
  background-color: #B11718;
}
#cssmenu li a:hover,
#cssmenu li.active {
  background-color: #DE3330;
}

我尝试按照在线教程了解如何执行此操作,我听说它隐藏然后出现在块中。

<ul> 
    <li>
    <ul>
        <li></li>
    <ul>
    </li> 
</ul>

如果我不正确的话,有点像这种格式......谁能帮我把当前菜单变成一个可能的下拉菜单。我按照教程进行操作,但它不会排列 Oo

请帮忙。对不起这个可怕的问题。它更多的是我将如何去做。

4

2 回答 2

0

将此添加到您的 CSS

#cssmenu ul li ul {
  position: absolute;
  top: 33px;
  height: auto;
  margin-left: 0;
  display: none;
}
#cssmenu ul li:hover ul {
  display: block;
}
#cssmenu ul li ul li {
  display: block;
  float: left;
  clear: both;
}

并关闭<li>内部<ul>

<ul class="sub1">
   <li><a href='team'><span>Team1</span></a></li>
   <li><a href='team'><span>Team2</span></a></li>
</ul>
于 2013-09-24T03:39:01.030 回答
0

像这样的东西?

#cssmenu ul {
  list-style-type: none;
  position: relative;
  display: block;
  font-size: 12px;
  background: url(../images/bg.png) repeat-x top left;
  font-family: Verdana, Helvetica, Arial, sans-serif;
  border: 1px solid #000;
  margin: 0;
  padding: 0;
  width: auto;
}
 #cssmenu li {
  display: inline-block;
  margin: 0;
  padding: 0;
}
 #cssmenu li ul {
     position: absolute;
    display: none;
}
/* Uncomment for vertical dropdown */
/*#cssmenu li ul li {
    display: block;
}*/
 #cssmenu li:hover ul {
    display: block;
}
#cssmenu li a {
    display: block;
  color: #A79787;
  text-decoration: none;
  padding: 9px 15px;
 font-weight: normal;
}
#cssmenu li a:hover,
#cssmenu .active {
  color: #fff;
  background: url(../images/bg.png) repeat-x top left;
  text-decoration: none;
}
#cssmenu .active a {
  color: #fff;
  font-weight: 700;
}
#cssmenu ul {
  background-color: #B11718;
}
#cssmenu li a:hover,
#cssmenu li.active {
  background-color: #DE3330;
}

http://jsfiddle.net/VUpFj/1/

于 2013-09-24T03:17:13.053 回答