简体   繁体   English

悬停在父级列表项上时更改链接颜色时的奇怪行为

[英]strange behaviour when changing the color of link when hovering on parent list item

My issue can be seen here - http://jsfiddle.net/aBSyH/3/ 我的问题可以在这里看到-http: //jsfiddle.net/aBSyH/3/

I'm using cufon text replacement and think that's the source of the issue. 我正在使用cufon文本替换,并且认为这是问题的根源。

The link's color should change when you hover in and out of the list item and it's content. 当您将鼠标悬停在列表项及其内容中时,链接的颜色应该会更改。 But it's behaving quite strangely. 但是它的表现很奇怪。 It changes back to blue sometimes but generally stay red. 有时会变回蓝色,但通常保持红色。

There seems to be something wrong with using cufon text and a selector like - 使用cufon文字和类似-的选择器似乎出现了问题

li.mainmenu:hover a {
    color:red;   
}

The cufon text does not revert to it's original colour when the mouse leaves the li's hover area. 当鼠标离开li的悬停区域时,cufon文本不会恢复为原始颜色。

Any idea why? 知道为什么吗?

I'd prefer to fix the issue without adding any javascript (apart from chaging the cufon initialisation code). 我希望在不添加任何JavaScript的情况下解决此问题(除了更改cufon初始化代码外)。

This post offers an explanation of your problem. 这篇文章提供了您的问题的解释。 In your case 就你而言

    Cufon.replace('li>a>li', {        
          hover: true
    });

fixes the issue. 解决此问题。

Marjin pointed me in the right direction, if I could up vote his answer again I would. Marjin向我指出了正确的方向,如果我能再次投票赞成他的回答,我会。

I really should have read the instructions to begin with - https://github.com/sorccu/cufon/wiki/FAQ#wiki-faq-10 我真的应该已经阅读了开始的说明-https: //github.com/sorccu/cufon/wiki/FAQ#wiki-faq-10

This is how I fixed it - 这就是我解决的方法-

Cufon.replace('ul#onesite_navigation > li', {
    hover: true,
    hoverables: { li: true },
    ignore: { ul: true },
    textless: { li: true }
});

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

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