如题所述
一般出现这种情况,往往是这个宽度的问题。宽度没有写死,正常的时候的一级菜单的宽度和hover状态下一级菜单的宽度不同,所以会掉下来。
下面有一个二级菜单的demo,可以对照着找一下
<!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=utf-08" />
<title>dropline-水平三级横向弹出菜单</title>
<style type="text/css">
/* common styling */
.hd3_nav {font-family: arial, sans-serif; width:749px; height:30px; position:relative; margin:0; font-size:11px; margin:0; background:#fff; position:relative;}
.hd3_nav ul {padding:0; margin:0; list-style-type: none;}
.hd3_nav ul li {float:left; border-left:1px solid #eee; width:106px;}
.hd3_nav ul li a, .hd3_nav ul li a:visited {display:block; float:left; width:101px; text-decoration:none; padding:0 0 0 5px; height:30px; line-height:30px; color:#000; background:#c9c9a7 url(../../graphics/drop.gif) bottom right no-repeat;}
.hd3_nav ul li ul {display: none;}
/* specific to non IE browsers */
.hd3_nav ul li:hover a {color:#fff; background:#b3ab79;}
.hd3_nav ul li:hover ul {display:block; position:absolute; width:749px; top:30px; left:0; background:#b3ab79; color:#fff;}
.hd3_nav ul li:hover ul.right_side li {float:right; border:0; border-left:1px solid #eee;}
.hd3_nav ul li:hover ul.left_side li {float:left; border:0; border-left:1px solid #eee;}
.hd3_nav ul li:hover ul li a.hide {background:#bd8d5e url(../../graphics/drop2.gif) bottom right no-repeat; color:#fff;}
.hd3_nav ul li:hover ul li:hover a.hide {background:#b3ab79; color:#fff;}
.hd3_nav ul li:hover ul li ul {display: none;}
.hd3_nav ul li:hover ul li a {display:block; background:##b3ab79; color:#fff;}
.hd3_nav ul li:hover ul li a:hover {background:#dfc184; color:#000;}
.hd3_nav ul li:hover ul li:hover ul {display:block; position:absolute; left:0; top:30px; color:#000; background:#dfc184;}
.hd3_nav ul li:hover ul.right li {float:right;}
.hd3_nav ul li:hover ul li:hover a.hide {background:#dfc184; color:#000;}
</style>
</head>
<body>
<div class="hd3_nav">
<ul>
<li><a class="hide" href="../hd3_nav/index.html">第1个</a>
<ul>
<li><a href="../hd3_nav/zero_dollars.html" title="The zero dollar ads page">zero dollars</a></li>
<li><a href="../hd3_nav/embed.html" title="Wrapping text around images">wrapping text</a></li>
<li><a href="../hd3_nav/form.html" title="Styling forms">styled form</a></li>
<li><a href="../hd3_nav/nodots.html" title="Removing active/focus borders">active focus</a></li>
<li><a href="../hd3_nav/hover_click.html" title="Hover/click with no active/focus borders">HOVER/CLICK</a></li>
<li><a href="../hd3_nav/shadow_boxing.html" title="Multi-position drop shadow">shadow boxing</a></li>
<li><a href="../hd3_nav/old_master.html" title="Image Map for detailed information">image map</a></li>
</ul>
</li>
<li><a class="hide" href="index.html">第2个</a>
<ul>
<li><a href="spies.html" title="a coded list of spies">spies hd3_nav</a></li>
<li><a href="vertical.html" title="a horizontal vertical hd3_nav">vertical hd3_nav</a></li>
<li><a href="expand.html" title="an enlarging unordered list">enlarging list</a></li>
<li><a href="enlarge.html" title="an unordered list with link images">link images</a></li>
<li><a href="cross.html" title="non-rectangular links">non-rectangular</a></li>
<li><a href="jigsaw.html" title="jigsaw links">jigsaw links</a></li>
<li><a href="circles.html" title="circular links">circular links</a></li>
</ul>
</li>
<li><a class="hide" href="../layouts/index.html">第3个</a>
<ul>
<li><a href="../layouts/bodyfix.html" title="Cross browser fixed layout">Fixed 1</a></li>
<li><a href="../layouts/body2.html" title="Cross browser fixed layout">Fixed 2</a></li>
<li><a href="../layouts/body4.html" title="Cross browser fixed layout">Fixed 3</a></li>
<li><a href="../layouts/body5.html" title="Cross browser fixed layout">Fixed 4</a></li>
<li><a href="../layouts/minimum.html" title="A simple minimum width layout">minimum width</a></li>
</ul>
</li>
<li><a class="hide" href="../boxes/index.html">第4个</a>
<ul>
<li><a href="spies.html" title="a coded list of spies">spies hd3_nav</a></li>
<li><a href="vertical.html" title="a horizontal vertical hd3_nav">vertical hd3_nav</a></li>
<li><a href="expand.html" title="an enlarging unordered list">enlarging list</a></li>
<li><a href="enlarge.html" title="an unordered list with link images">link images</a></li>
<li><a href="cross.html" title="non-rectangular links">non-rectangular</a></li>
<li><a href="jigsaw.html" title="jigsaw links">jigsaw links</a></li>
<li><a href="circles.html" title="circular links">circular links</a></li>
</ul>
</li>
<li><a class="hide" href="../mozilla/index.html">第5个</a>
<ul>
<li><a href="../mozilla/dropdown.html" title="A drop down hd3_nav">drop down hd3_nav</a></li>
<li><a href="../mozilla/cascade.html" title="A cascading hd3_nav">cascading hd3_nav</a></li>
<li><a href="../mozilla/content.html" title="Using content:">content:</a></li>
<li><a href="../mozilla/moxbox.html" title=":hover applied to a div">mozzie box</a></li>
<li><a href="../mozilla/rainbow.html" title="I can build a rainbow">rainbow box</a></li>
<li><a href="../mozilla/snooker.html" title="Snooker cue">snooker cue</a></li>
<li><a href="../mozilla/target.html" title="Target Practise">target practise</a></li>
</ul>
</li>
<li><a class="hide" href="../ie/index.html">第6个</a>
<ul class="right_side">
<li><a href="../ie/exampleone.html" title="Example one">example one</a></li>
<li><a href="../ie/weft.html" title="Weft fonts">weft fonts</a></li>
<li><a href="../ie/exampletwo.html" title="Vertical align">vertical align</a></li>
</ul>
</li>
<li><a class="hide" href="../opacity/index.html">第6个</a>
<ul class="right_side">
<li><a href="../opacity/colours.html" title="colour wheel">opaque colours</a></li>
<li><a href="../opacity/picturehd3_nav.html" title="a hd3_nav using opacity">opaque hd3_nav</a></li>
<li><a href="../opacity/png.html" title="partial opacity">partial opacity</a></li>
<li><a href="../opacity/png2.html" title="partial opacity II">partial opacity II</a></li>
<li><a href="../hd3_nav/hover_click.html" title="Hover/click with no active/focus borders">HOVER/CLICK</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考
第1个回答 2016-07-25
有图片吗 详细点 谢谢