Javascript 固定屏幕顶部的菜单和徽标
我试图得到一个徽标和一个菜单栏,它将固定在屏幕顶部的内容页面上,然后在鼠标上方,你会得到一个简短的水平菜单,在其中一个项目上还有一个下拉子菜单 我曾经尝试过像这样使用一些JavaScript,但发现它在一定宽度的页面上不起作用Javascript 固定屏幕顶部的菜单和徽标,javascript,html,Javascript,Html,我试图得到一个徽标和一个菜单栏,它将固定在屏幕顶部的内容页面上,然后在鼠标上方,你会得到一个简短的水平菜单,在其中一个项目上还有一个下拉子菜单 我曾经尝试过像这样使用一些JavaScript,但发现它在一定宽度的页面上不起作用 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <htm
<!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>
梅恩乌
因此,考虑尝试一下如何使用
,看看我是否可以让它使用它。与从头开始编写Javascript不同,您可以探索类似的开源替代方案。你甚至可以试试。这些是一些可以满足您需求的快速替代方案
您可以参考他们的源代码以更好地理解。我已经看到了与您在Twitter引导中提到的完全相同的功能。试试看。哦,太棒了,我来看看,谢谢。我正在将它应用到Joomla中,我知道Bootstrap是以某种方式集成的。干杯