简体   繁体   English

为什么我的Superfish菜单在Firefox中无法正常运行?

[英]Why isn't my Superfish menu working properly in Firefox?

I'm trying to use Superfish jQuery plugin to enhance a drop-down menu on a website. 我正在尝试使用Superfish jQuery插件来增强网站上的下拉菜单。 However, the drop-down menu doesn't open when the cursor hovers over it in Firefox browser (v. 21.0) as it should. 但是,当光标在Firefox浏览器(v.21.0)中悬停时,下拉菜单不会打开。 In Chrome and Opera it works. 在Chrome和Opera中它可以工作。 Without the Superfish plugin the drop-down menu works also in Firefox with plain CSS. 如果没有Superfish插件,下拉菜单也可以在Firefox中使用纯CSS。

When using the cssArrows option for Superfish, the arrows don't show up in any browser (even when using more padding). 当使用Superfish的cssArrows选项时,箭头不会显示在任何浏览器中(即使使用更多填充)。 I don't know if this problem is related to the first one. 我不知道这个问题是否与第一个问题有关。

Here's my markup: 这是我的标记:

<nav>
    <ul>
        <li><a href="#">Page 1</a></li>
        <li>
            <a href="#">Page 2</a>
            <ul>
                <li><a href="#">Page 2.1</a></li>
                <li><a href="#">Page 2.2</a></li>
                <li><a href="#">Page 2.3</a></li>
            </ul>
        </li>
        <li><a href="#">Page 3</a></li>
        <li><a href="#">Page 4</a></li>
        <li><a href="#">Page 5</a></li>
    </ul>
</nav>

And here's my CSS/SASS: 这是我的CSS / SASS:

 nav {
    width: 100%;
    float: left;

    ul {
        display: block;
        float: left;
        width: 100%;

        li {
            position: relative;
            display: block;
            float: left;

            a {
                display: block;
                padding: 14px 14px;
            }
            /* drop-down */
            ul {
                display: none;
                position: absolute;
                left: 0;
                top: 100%;
                padding: 0;
                border: 1px solid #aaa;
                border-top-width: 0;

                li {
                    float: none;
                    a {
                        padding: 8px 3px;
                        border-top: 1px solid #aaa;
                    }
                }
            }

            &:hover,
            &.sfHover {
                ul {
                    display: block;
                }
            }
        }
    }
}

Here's my Superfish call: 这是我的Superfish电话:

$('nav').superfish();

In Firefox, when I hover over the li tag that holds the second level menu, the li doesn't get sfHover class as should happen. 在Firefox中,当我将鼠标悬停在包含第二级菜单的li标签上时, li不会获得应该发生的sfHover类。 Instead, the top-level ul gets sfHover class assigned to it. 相反,顶级ul获得分配给它的sfHover类。 Then, when I press left mouse button down on that li tag, it gets the 'sfHover' tag and the drop-down menu shows up. 然后,当我在那个li标签上按下鼠标左键时,它会获得'sfHover'标签并显示下拉菜单。 In Chrome and Opera sfHover class gets assigned to the right elements. 在Chrome和Opera中, sfHover类被分配给正确的元素。

The examples from Superfish plugin's site work also in my Firefox browser but they didn't help me to solve this. Superfish插件的网站上的示例也在我的Firefox浏览器中工作,但它们并没有帮助我解决这个问题。 My html markup for the menu is almost the same as in those examples. 菜单的html标记与这些示例几乎相同。

I've tried to 我试过了

  • assign z-indexes to different elements, but it didn't help (didn't expect to). 将z-indexes分配给不同的元素,但它没有帮助(没想到)。 Currently no element on the page has z-index assigned to it. 目前,页面上没有任何元素为其分配了z-index。
  • assign widths on li and a elements since I had read that it had helped in some problem situations. lia元素分配宽度,因为我读过它在某些问题情况下有所帮助。
  • use the stylesheets from Superfish examples but they didn't work any better. 使用来自Superfish示例的样式表,但它们没有更好的工作。
  • hide the drop-down menu with margin-left: -9999px instead of display: none but that didn't help. 使用margin-left: -9999px隐藏下拉菜单margin-left: -9999px而不是display: none但这没有帮助。
  • use all options when initializing Superfish 初始化Superfish时使用所有选项
  • use position: relative on a tags instead of on li tags 使用position: relative上的a标签,而不是对li标签

I've also checked that my html validates. 我还检查过我的html验证。

Can anyone figure out what's the problem? 任何人都可以找出问题所在? I'd greatly appreciate any suggestions. 我非常感谢任何建议。

I can't test it in Firefox 21, as my Firefox has just updated to 22. 我无法在Firefox 21中测试它,因为我的Firefox刚刚更新到22。

But in 22 it works as expected, here's where i tested: http://jsbin.com/okafoz/1/edit 但在22它按预期工作,这是我测试的地方: http//jsbin.com/okafoz/1/edit

It is probably a non-Superfish related issue. 这可能与非Superfish相关。

Ok, the problem wasn't jQuery version. 好的,问题不是jQuery版本。 I think I just momentarily misthought it worked. 我想我只是暂时误以为它有效。

I'm using wordpress 3.5.2 in the project and it conflicted with superfish. 我在项目中使用wordpress 3.5.2,它与superfish冲突。 I don't have time to look too much into it right now, but this much I found out: 我现在没时间看太多了,但是我发现了这么多:

wp-includes/js/admin-bar.min.js uses hoverIntent function, if at the time of execution of that script jQuery is already included but hoverIntent isn't defined, it defines function jQuery.fn.hoverIntent itself. wp-includes / js / admin-bar.min.js使用hoverIntent函数,如果在执行该脚本时jQuery已经包含但是hoverIntent没有定义,它定义了函数jQuery.fn.hoverIntent本身。

hoverIntent jQuery plugin can be optionally used with superfish. hoverIntent jQuery插件可以选择与superfish一起使用。 superfish calls hoverIntent function of that plugin once, if it's defined. 如果已定义,superfish会调用该插件的hoverIntent函数一次。 This call caused my drop-down menu to not show up, since it caused an error when I hovered cursor over the list item holding a submenu ("b.browser is not defined" in admin-bar.min.js). 此调用导致我的下拉菜单不显示,因为当我将光标悬停在包含子菜单的列表项上时(“admin.bar.min.js中未定义b.browser”),它会导致错误。

The reason it only showed up in Firefox was that I was only logged in to this wordpress site in Firefox, not in other browsers... 它只出现在Firefox中的原因是我只登录到Firefox中的wordpress网站,而不是其他浏览器...

But: there's an option disableHI in superfish. 但是:在disableHI中有一个选项disableHI。 If you set that to true , superfish won't call hoverIntent. 如果将其设置为true ,则superfish不会调用hoverIntent。 I thought I had tried that option already but anyway, it worked of course. 我以为我已经尝试过这个选项,但无论如何,它当然有效。

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

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