简体   繁体   English

jQuery菜单按钮仅在webkit的下拉菜单中消失,如何使它保持原状?

[英]jQuery Menu Button Disappearing on drop down in webkit only, how do I make it stay put?

I have a problem involving jQuery drop downs. 我有一个涉及jQuery下拉列表的问题。 Basically the button which reveals the drop down dissapears upon revealing the drop down. 基本上,显示下拉菜单的按钮在显示下拉菜单时消失。 Here is the code 这是代码

The HTML included in the navigation 导航中包含的HTML

<div id="header">
<div id="navHolder">
        <ul style="list-style: none;">
        <li><a href="#" class="navBtn">Travel Blog</a></li>
        <ul class="dropdown">
        <li><a href="#" class="navBtn">Destination</a>
            <ul class="sub_menu">
                 <li><a href="#">Item One</a></li>
                 <li><a href="#">Item Two</a></li>
                 <li><a href="#">Item Three</a></li>
            </ul>
        </li>
        </ul>
    <li><a href="#" class="navBtn">Map</a></li>
    <li><a href="#" class="navBtn">About</a></li>
    </ul>
</div>

This is the javascript generating the drop down effect 这是生成下拉效果的JavaScript

$(function(){

var config = {    
     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
     interval: 200,  // number = milliseconds for onMouseOver polling interval    
     over: doOpen,   // function = onMouseOver callback (REQUIRED)    
     timeout: 200,   // number = milliseconds delay before onMouseOut    
     out: doClose    // function = onMouseOut callback (REQUIRED)    
};

function doOpen() {
    $(this).addClass("hover");
    $('ul:first',this).css('visibility', 'visible');
}

function doClose() {
    $(this).removeClass("hover");
    $('ul:first',this).css('visibility', 'hidden');
}

$("ul.dropdown li").hoverIntent(config);

$("ul.dropdown li ul li:has(ul)").find("a:first").append(" &raquo; ");

}); });

And this is the CSS styling the buttons and drop down... 这是CSS样式化按钮并下拉菜单...

ul.dropdown                         { position: relative; list-style: none;}
ul.dropdown li                      { font-weight: bold;  list-style: none; zoom: 1;}
ul.dropdown a:hover                 { color: #CCC; }
ul.dropdown a:active                { color: #FFF; }
ul.dropdown li a                    { display: block; color: #FFF;}
ul.dropdown li:last-child a         { border-right: none; } /* Doesn't work in IE */
ul.dropdown li.hover,
ul.dropdown li:hover                { color: #CCC; position: relative; }
ul.dropdown li.hover a              { color: #FFF; text-decoration: none;}
ul.dropdown ul                      { width: 180px; background: url(images/transBlack_bg2.png) repeat; -moz-border-radius: 5px; -webkit-border-radius: 5px; visibility: hidden; position: absolute; top: 45px; right: 60px; }
ul.dropdown ul li                   { font-weight: bold; font-size: 13px; color: #FFF; padding: 5px;}
ul.dropdown ul li a                 { width: auto; display: inline-block; } 
ul.dropdown ul li a:hover           { color: #111;}
ul.dropdown ul ul                   { left: 100%; top: 0; }
ul.dropdown li:hover > ul           { visibility: visible; }

Any advice or answers will be greatly appreciated, thanks very much for your time :) 任何建议或答案将不胜感激,非常感谢您的时间:)

The problem is you are using the pseudo hover class incorrectly. 问题是您使用的伪悬停类不正确。 This link specifies how to use them properly. 此链接指定如何正确使用它们。 Your problem is this (from link): Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective!! 您的问题是这个(来自链接):注意:a:hover必须在CSS定义中的a:link和a:visit之后,才能生效! So your hover style is not behaving correctly. 因此,您的悬停样式行为不正确。 If you add these lines (adjusting as desired): 如果添加这些行(根据需要进行调整):

ul.dropdown li.hover a:link {color:#999}
ul.dropdown li.hover a:visited {color:#999}

before this line: 在此行之前:

ul.dropdown li.hover a              { color: #FFF; text-decoration: none;} 

it will work as expected. 它会按预期工作。

Edit: Also, using a class named hover along with the hover pseudo class makes the css pretty hard to decipher. 编辑:此外,使用名为hover的类以及hover伪类使css很难破解。 I'd give the class you create a different name if possible. 如果可以的话,我会给您创建一个不同的名称的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM