0

我的下拉菜单有问题。打开时下拉菜单向右展开。我检查边距、填充和白色值,但我没有找到解决方案。这里有实时示例

演示

HTML:

<div id="header">  
   <div class="nav">
        <ul>
            <li><span class="home"></span><a href="#index.html">Lorem ipsum</a></li>
            <li><span class="department"></span><a href="#department.html" class="drop_down">Lorem ipsum</a>
                <ul id="submenu">
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                    <li><a href="#">Lorem ipsum</a></li>
                </ul>
            </li>
            <li><span class="index"></span><a href="#">Lorem ipsum</a></li>
        </ul>
    </div>
</div>

CSS:

#header .nav{background:green; height:42px;font-family:Arial;}
#header .nav ul{margin:0;padding:0;list-style:none;}
#header .nav ul li{float:left;padding:10px 20px 0 20px;border-right:solid 1px #ccc;height:32px;}
#header .nav ul li a{color:#fff;text-decoration:none;font-size:0.8em;}
#header .nav ul li span{height:17px;margin:3px 10px 0 0;float:left;}
#header .nav ul li span.home{background:url('../image/home.png') no-repeat left top;width:18px;}
#header .nav ul li span.department{background:url('../image/department.png') no-repeat left top;width:18px;}
#header .nav ul li span.index{background:url('../image/index.png') no-repeat left top;width:17px;}
#header .nav ul li span.recipe{background:url('../image/recipe.png') no-repeat left top;width:14px;}
#header .nav ul li span.car{background:url('../image/car.png') no-repeat left top;width:17px;}
#header .nav ul li a.drop_down{background:url('../image/arrow_down.png') no-repeat 50px 4px;width:17px;padding-right:14px;}
#header .nav ul li ul#submenu{position:absolute;display:none;margin:13px 0 0 -20px;border-top:solid 1px #ccc;}
#header .nav ul li ul#submenu li{clear:both;background:blue; height:42px;font-family:Arial;border-bottom:solid 1px #ccc;margin:0;padding:5px;width:100%;display:inline-block;}​

JS:

    $(function(){
        $(".drop_down").hover(
            function(){
                $("ul#submenu").stop(true,true).slideDown("slow",function(e){
                    $(this).hover(
                        function(){
                            $(this).show();
                        },
                        function(){
                            $(this).slideDown();
                        }
                    );
                });
            },
            function(){
                $("ul#submenu").stop(true,true).slideUp("slow");
            }
        );
    });​

​</p>

4

2 回答 2

1

width: 100%;#header .nav ul li ul#submenu li导致这种情况下,请提供一些固定宽度100px;,这将解决您的扩展宽度错误。

我的小提琴

于 2012-07-30T05:36:08.183 回答
0

当更改宽度值修复而不是百分比时问题解决了。谢谢外星人先生。

于 2012-07-30T05:45:39.863 回答