下面是我用于下拉菜单的代码。它在 Firefox 中运行良好,但在 IE 中存在一个问题。在 IE 的菜单下留下大约 30 像素的空白区域。请帮助解决此问题。
谢谢,
----- HTML 代码 -----
<table width="79" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="79" height="75" align="left" valign="top">
<ul id="sddm"><li><a href="about.php" onMouseOver="mopen('m2')" onMouseOut="mclosetime()"><img src="./images/btn_about.jpg" border="0"/></a>
<div id="m2" onMouseOver="mcancelclosetime()" onMouseOut="mclosetime()">
<a href="event_calendar.php">Events</a>
<a href="latest_updates.php">Updates</a>
</div>
</li></ul>
<div style="clear:both"></div>
</td>
</tr>
</table>
----- CSS 代码 -----
#sddm
{
margin: 0;
padding: 0;
z-index: 2;
}
#sddm li
{
margin: 0;
padding: 0;
list-style: none;
float: center;
font: 12px arial;
}
#sddm li a
{
display: block;
margin: 0 0px 0 0;
padding: 0px 0px;
width: 0px;
height:0px;
background: #;
font: 13px arial;
color: #FFE792;
text-align: center;
text-decoration: none;
}
#sddm li a:hover
{
background: #;
}
#sddm div
{
position: absolute;
visibility: hidden;
margin: 0;
padding: 0;
background: #EAEBD8;
border: 1px solid #8A0058;
}
#sddm div a
{
position: relative;
display: block;
margin: 0;
padding: 3px 4px;
width: auto;
white-space: nowrap;
text-align: left;
text-decoration: none;
background: #B31C7C;
color: #FFFFFF;
font: 12px arial
}
#sddm div a:hover
{
background: #FF00A3;
color: #FFFFFF;
}
----- JAVASCRIPT 代码 -----
<script language="JavaScript" type="text/javascript">
var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;
// open hidden layer
function mopen(id)
{
// cancel close timer
mcancelclosetime();
// close old layer
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
// get new layer and show it
ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = 'visible';
}
// close showed layer
function mclose()
{
if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}
// go close timer
function mclosetime()
{
closetimer = window.setTimeout(mclose, timeout);
}
// cancel close timer
function mcancelclosetime()
{
if(closetimer)
{
window.clearTimeout(closetimer);
closetimer = null;
}
}
// close layer when click-out
document.onclick = mclose;
</script>