日期:2014-05-17  浏览次数:20608 次

【求助】UL下的子菜单会自动内联?
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
</head> 
<style>
ul {
    margin: 0px;
    padding: 0px;
    background:#333;
    width:949px;
}
ul li{float:left;
      display:inline;
      list-style:none;
      height:30px;
      width:100px;}
ul li ul{display:block ;}



      

</style>
 <div style="width:949;">
<ul>
<li><a href="#"><span>ALL</span></a>
    <ul>
      <li style="display:block"><a href="#"><span>all</span></a></li>
      <li style="display:block"><a href="#"><span>all</span></a></li>
      <li style="display:block"><a href="#"><span>all</span></a></li>
      <li style="display:block"><a href="#"><span>all</span></a></li>
    </ul> 
</li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
</ul>
</div>


------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
</head> 
<style>
ul.menu {
    margin: 0px;
    padding: 0px;
    background:#333;
    width:949px;
}
ul.menu li{float:left;
      display:inline;
      list-style:none;
      height:30px;
      width:100px;}
ul.menu li ul{display:block ;}



      

</style>
 <div style="width:949;">
<ul class="menu">
<li><a href="#"><span>ALL</span></a>
    <ul>
      <li style="display:block"><a href="#"><span>all</span></a></li>
      <li style="display:block"><a href="#"><span>all</span></a></li>
      <li style="display:block"><a href="#"><span>all</span></a></li>
      <li style="display:block"><a href="#"><span>all</span></a></li>
    </ul> 
</li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
<li><a href="#"><span>name</span></a></li>
</ul>
</div>