代码如下:
<!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=gb2312" />
<title>Untitled Document</title>
<style type="text/css">
#title1 {
list-style-type:none;
}
a:link {
color:red;text-decoration:none;
}
a:visited {
color:black;text-decoration:none;
}
a:hover {
color:yellow;text-decoration:underline;
}
#title1 li{
float:left;margin:0px;background-color:#99CCCC;
}
#title1 li a{
display:block;text-align:center;width:60px;
}
#title1 li ul{left:-999em;position:absolute;}
#title1 li ul li a{width:160px;}
#title1 li.hfhover ul{left:auto;}
</style>
<script type=text/javascript>
function menuFix()
{
var sfEls = document.getElementById("title1").getElementsByTagName("li");
for (var i=0; i<sfEls.length; i++)
{
sfEls[i].onmouseover=function()
{
this.className+="hfhover";
}
sfEls[i].onmouseout=function()
{
this.className=this.className.replace("hfhover","");
}
}
}
window.onload=menuFix;
</script>
</head>
<body>
<ul id="title1">
<li>
<a href="#">娱乐</a>
<ul>
<li><a href="#">国内娱乐</a></li>
<li><a href="#">国外娱乐</a></li>
</ul>
</li>
<li>
<a href="#">新闻</a>
<ul>
<li><a href="#">国内新闻</a></li>
<li><a href="#">国外新闻</a></li>
</ul>
</li>
<li>
<a href="#">体育</a>
<ul>
<li><a href="#">国内体育</a></li>
<li><a href="#">国外体育</a></li>
</ul>
</li>
</ul>
</body>
</html>