1

我有一个菜单结构:

<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 &amp; 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 &amp; 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 &amp; 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;
}
4

2 回答 2

1

像这样

演示

CSS

#nav_menu ul{
    margin:0;
    padding:0;
    float:left;
}
#nav_menu li {
    display: inline;
    float: left;
    padding-right: 3px;
    position: relative;
     border-bottom:#FFD700 3px solid;
}

#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;
    line-height: 20px;
    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: 20px;
    width: 140px;
    z-index: 2;
}
于 2013-08-16T07:29:49.980 回答
0

prueba lo siguiente:

演示 1

JAVASCRIPT

$(document).ready(function()
{
    $("div.po").set_ELEMENT(
    {
        bgColor:'red',

        click: function(oThis)
        {
            oThis.find('> div').css({'color':'red','background-color' : 'blue'});
        }
     });
});
于 2014-10-03T08:37:59.717 回答