我正在尝试获取一个徽标和一个菜单栏,它们将在内容分页上固定到屏幕顶部,然后在鼠标悬停时您会得到一个简短的水平菜单,其中一个项目上有一个进一步的下拉子菜单。
我正在尝试像这样使用一些 JavaScript,但发现它不适用于超过一定宽度的页面。
<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
<style type="text/css">
<!--
/* set the menu style */
#menu1 {position: absolute;left:0px;;width: 745px;}
.menuHead { font-weight: bold; font-size: larger; background-color: #A9A9A9;height:40px;padding-top:10px; text-align:center;
background-image: -webkit-linear-gradient(left, #b4872a, #ffe792, #b4872a);
background-image: -moz-linear-gradient(left, #b4872a, #ffe792, #b4872a);
background-image: -ms-linear-gradient(left, #b4872a, #ffe792, #b4872a);
background-image: -o-linear-gradient(left, #b4872a, #ffe792, #b4872a);}
.menuChoices { background-color: #000; /*opacity:0.4;filter:alpha(opacity=40);*/height:70px;padding-top:35px;}
.menu a {color: #e3c96b; text-decoration: none;margin:0px 25px;}
.menu a:hover {text-decoration: underline;}
/* position your menus */
-->
</style>
<script type="text/javascript">
<!--
/* we'll only allow DOM browsers to simplify things*/
(document.getElementById ? DOMCapable = true : DOMCapable = false);
function hide(menuName)
{
if (DOMCapable)
{
var theMenu = document.getElementById(menuName+"choices");
theMenu.style.visibility = 'hidden';
}
}
function show(menuName)
{
if (DOMCapable)
{
var theMenu = document.getElementById(menuName+"choices");
theMenu.style.visibility = 'visible';
}
}
//-->
</script>
</head>
<body>
<div id="menu1" class="menu" onmouseover="show('menu1');" onmouseout="hide('menu1');">
<div class="menuHead">M E N U</div>
<div id="menu1choices" class="menuChoices">
<a href="http://www.google.com">menu1</a>
<a href="http://www.yahoo.com">menu2</a>
<a href="http://www.teoma.com">menu3</a>
<a href="http://www.msn.com">menu4</a>
<a href="http://www.altavista.com">Country Selector</a>
</div>
</div>
<script type="text/javascript">
<!--
/* Don't hide menus for JS off and older browsers */
if (DOMCapable)
{
hide("menu1");
}
//-->
</script>
</body>
</html>
所以想尝试一下<ul><li>
,看看我是否可以让它与它一起工作。