<!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-8" />
<title>无标题文档</title>
<style type="text/css" >
#tabMenu a{
background-color:#ccc;//背景颜色灰色
text-decoration:none;//无下划线
width:200px;
height:30px;
text-align:center;//文字左右居中
line-height:30px;//文字上下居中
border:1px solid white;//边框
color:black;
display:block;//block是有结构的,inline是没有结构的(无宽和高)
}
#tabMenu a:hover{
background:#F00;
color:#FFF;
}
.divMenu{
display:none; //设置为隐藏
z-index:9px;//设置级别为9,
position:absolute;/设置为绝对定位
}
</style>
<script type="text/javascript" language="javascript">
function showMenu(obj){
document.getElementById("Menu"+obj).style.display="block";
}
function hideMenu(obj){
document.getElementById("Menu"+obj).style.display="none";
}
</script>
</head>
<body>
<table id="tabMenu" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><a href="#" onmouseover="showMenu(1);" onmouseout="hideMenu(1);">公司首页</a>
</td>
<td><a href="#" onmouseover="showMenu(2);" onmouseout="hideMenu(2);">新闻中心</a>
</td>
<td><a href="#" onmouseover="showMenu(3);" onmouseout="hideMenu(3);">产品首页</a>
</td>
</tr>
<tr>
<td>
<div id="Menu1" class="divMenu" onmousemove="showMenu(1);" onmouseout="hideMenu(1);">
<a href="#"/>公司首页1</a>
<a href="#"/>公司首页1</a>
<a href="#"/>公司首页1</a>
<a href="#"/>公司首页1</a>
<a href="#"/>公司首页1</a>
</div>
</td>
<td>
<div id="Menu2" class="divMenu" onmousemove="showMenu(2);" onmouseout="hideMenu(2);">
<a href="#"/>产品首页1</a>
<a href="#"/>产品首页1</a>
<a href="#"/>产品首页1</a>
<a href="#"/>产品首页1</a>
<a href="#"/>产品首页1</a>
</div>
</td>
<td>
<div id="Menu3" class="divMenu" onmousemove="showMenu(3);" onmouseout="hideMenu(3);">
<a href="#"/>新闻首页1</a>
<a href="#"/>新闻首页1</a>
<a href="#"/>新闻首页1</a>
<a href="#"/>新闻首页1</a>
<a href="#"/>新闻首页1</a>
</div>
</td>
</tr>
</table>
<img src="advpic.gif"/>
</body>
</html>
HTML实现菜单功能
最新推荐文章于 2025-06-06 14:59:57 发布