当我将鼠标悬停在项目上时,我的CSS/JS下拉菜单不会保持在下
My CSS/JS drop down menu won't stay down when I hover over the items
我为这个下拉菜单添加了一个链接;当我将鼠标悬停在链接上时,菜单收缩到屏幕顶部,链接就像我将鼠标完全移出菜单一样消失了。这里是它的发布:http://camron.onyxtek.com/
Html:<body>
<div id="navigation">
<ul id="navlist">
<li class="titleli">
<a href="/" target="_self" id="titlelink">Some Title</a>
</li>
<li class="breadcrumb" id="bc1" onmouseover="bc1_MouseOver()"><p class="bctitle">Projects</p></li>
<li class="breadcrumb" id="bc2" onmouseover="bc2_MouseOver()"><p class="bctitle">Stuff</p></li>
</ul>
</div>
<div id="navmenu" onmouseover="nm_MouseOver()" onmouseout="nm_MouseOut()">
<ul id="ml1" class="menulist">
<li class="menuli">
<a class="menulink" href="/Main/AsciiPlatformer">Ascii Platformer</a>
</li>
</ul>
</div>
<div class="container">
@RenderBody()
</div>
</body>
CSS: #navigation, #navlist {
width: auto;
height: 50px;
}
#navigation {
background-color: #888;
margin: 0;
padding: 0;
}
#navmenu {
background-color: #aaa;
position: relative;
margin: 0, 0, 10px, 0;
height: 3px;
transition: height linear 0.25s;
}
#navlist {
list-style: none;
display: block;
clear: left;
}
#navlist li {
float: left;
display: block;
height: inherit;
margin-right: 10px;
}
#titleli {
background-color: #aaa;
}
#titlelink {
font-family: "Lucida Console", Monaco, monospace;
color: #ddd;
font-size: 25px;
text-decoration: none;
display: block;
margin: 12px 2px 0 10px;
}
.breadcrumb {
background-color: #999;
border-left: 2px solid #aaa;
border-right: 2px solid #aaa;
width: 100px;
}
.menulist {
display: none;
position: absolute;
list-style: none;
clear: left;
}
.menulink {
font-family: "Courier New", Courier, monospace;
color: #ddd;
font-size: 15px;
text-decoration: none;
display: block;
margin: 10px 0 0 10px;
}
.bctitle {
font-family: "Courier New", Courier, monospace;
color: #ddd;
font-size: 15px;
text-decoration: underline;
display: block;
margin: 18px 0 0 8px;
}
body {
background-color: #ddd;
}
body, div, ul, li, a {
margin: 0;
padding: 0;
border: 0;
}
JavaScript: var menuHover = false;
function resetColors() {
document.getElementById("bc1").style.backgroundColor = "#999";
document.getElementById("bc2").style.backgroundColor = "#999";
}
function showMenu(index, bool) {
if (bool) {
document.getElementById("ml" + index).style.display = "block";
} else {
document.getElementById("ml" + index).style.display = "none";
}
}
function bc1_MouseOver() {
resetColors();
document.getElementById("navmenu").style.height = "200px";
showMenu(1, true);
document.getElementById("bc1").style.backgroundColor = "#aaa";
}
function bc2_MouseOver() {
resetColors();
document.getElementById("navmenu").style.height = "200px";
showMenu(1, false);
document.getElementById("bc2").style.backgroundColor = "#aaa";
}
function nm_MouseOver() {
menuHover = true;
}
function nm_MouseOut() {
menuHover = false;
document.getElementById("navmenu").style.height = "3px";
showMenu(1, false);
resetColors();
}
您是否尝试将您的<li>
元素设置为在CSS中具有属性pointer-events: none
?
相关文章:
- JS在选择下拉菜单打开时创建延迟
- JS下拉菜单没有'不起作用
- JS下拉菜单显示在图像旋转器上
- 使用 d3.js 添加下拉菜单
- HTML、CSS、JS响应下拉菜单
- HTML下拉菜单's重定向(使用JS)不适用于移动设备,但在PC上运行良好
- 使用jQuery动态设计js下拉菜单的样式
- 使用 JS 在 Cloud 9 的下拉菜单中显示所有拉力赛项目
- JS下拉菜单未关闭
- 如何在我的js下拉菜单/显示内容框上的不同内容之间切换
- 无法在angular js中使用下拉菜单更改颜色
- 为什么我的css/js下拉菜单在到达它的末尾之前就隐藏了
- 有没有办法关闭typeahead.js的下拉菜单
- 为什么这个非常基本的JS下拉菜单不起作用
- 带有API.js的语义UI搜索选择下拉菜单-未发生API调用
- Ember.js中的Foundation.js下拉菜单
- 如何在Bootstrap select中的下拉菜单关闭时触发事件,并在Backbone.js中进行多选
- 使用 Greasemonkey 更改变量或激活 JS 链接的<选择>下拉菜单
- Angular JS下拉菜单使用ng点击和ng显示来显示动态内容
- 多个搜索选项,单个字段,通过下拉菜单js/jquery进行选择