我在下拉菜单上有问题。下拉菜单在open.i检查边距,填充和白色值时向右扩展但我找不到解决方案。这里有实时样本
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");
}
);
});
答案 0 :(得分:1)
答案 1 :(得分:0)
当更改宽度值而不是百分比时问题解决了。谢谢Alien先生。