我们公司为了让菜单突出显示,于是我想到了用button来实现,显示的效果如下:
当鼠标离开button时:
当鼠标在button上时:
实现的代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.btOver{
background-image:url();
background-position:2px 0;
background-repeat:no-repeat;
background-color:#00FFFF;
font-size:12px;
padding-left:16px;
cursor:hand;
}
.btOut{
background-image:url();
background-position:2px 0;
background-repeat:no-repeat;
background-color:#FFCCFF;
font-size:12px;
padding-left:16px;
cursor:default;
}
</style>
<script type="text/javascript">
function buttonMouseOver(btObj)
{
btObj.className="btOver";
}
function buttonMouseOut(btObj)
{
btObj.className="btOut";
}
</script>
</head>
<body>
<input type="submit" name="Submit" style="background-image:url(adddept.gif)" class="btOut" value="提交" onmouseover="buttonMouseOver(this)" onmouseout="buttonMouseOut(this)"/>
</body>
</html>