我有一个菜单结构:
<ul id="nav_menu">
<li><a href="#!index?category_id=3" class="subcategory">Electronics</a>
<ul>
<li><a href="#!index?category_id=15">Mobile phones</a></li>
</ul>
</li>
<li><a href="#!index?category_id=4">Computers</a></li>
<li><a href="#!index?category_id=5">Car Electronics</a></li>
<li><a href="#!index?category_id=6">TV & Video</a></li>
<li><a href="#!index?category_id=7">Cell Phones</a></li>
<li><a href="#!index?category_id=8">MP3 Players</a></li>
<li><a href="#!index?category_id=9">Cameras & Photo</a></li>
<li><a href="#!index?category_id=10">Apparel</a></li>
<li><a href="#!index?category_id=11">Music</a></li>
<li><a href="#!index?category_id=12">Movies & TV</a></li>
<li><a href="#!index?category_id=13">Video Games</a></li>
<li><a href="#!index?category_id=14">Office Supplies</a></li>
</ul>
但它看起来像下面这样:
如果我有很多类别并且我的设备屏幕宽度很窄,是否可以优化菜单?
我的 CSS:
#nav_menu li {
display: inline;
float: left;
padding-right: 3px;
position: relative;
}
#nav_menu > li > a {
background: none repeat scroll 0 0 #404040;
border-radius: 3px 3px 0 0;
color: #FFFFFF;
display: block;
font-size: 14px;
font-weight: bold;
height: 28px;
line-height: 28px;
padding: 0 5px;
text-decoration: none;
}
#nav_menu ul {
background: none repeat scroll 0 0 #404040;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.1);
list-style: none outside none;
margin: 0;
padding: 5px;
position: absolute;
top: 36px;
width: 140px;
z-index: 2;
}