jQuery 悬停在孩子身上时的怪异
Hover over green box, then move mouse to child list. Suddenly starts blinking like mad, anyway to prevent this but maintain the hover still over child?
*edited afterward
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是您的工作代码 http://jsfiddle.net/GNQyt/18
我用的是延迟的方法。离开
.icn
后,您有 1000 毫秒到达ul
。如果您在所需的时间内点击ul
,淡出的请求就会被删除。Here is your working code http://jsfiddle.net/GNQyt/18
I used the delay method. You have 1000ms once you leave the
.icn
to reach theul
. If you hit theul
in the desired time, the request for fading it out gets removed.http://jsfiddle.net/GNQyt/5/
使用 mouseenter,而不是悬停在这种情况下
这是“Mouseenter”与“Mouseover”的一个很好的互动比较 http://api.jquery.com/mouseover/
Demo说的很清楚了。
http://jsfiddle.net/GNQyt/5/
Use mouseenter, not hover in that case
Here is a nice little interactive comparison of "Mouseenter" vs. "Mouseover" http://api.jquery.com/mouseover/
The Demo makes it very clear.
闪烁是由于从绿色框移至弹出窗口而导致的。到 之间的距离导致计算机关闭弹出窗口,因为您已远离绿色框,但就在弹出窗口完全关闭之前,鼠标到达弹出窗口,导致其再次打开。理想情况下,两者应该相交,以允许鼠标直接从框移动到弹出窗口。或者,增加关闭弹出窗口之前的延迟。
The flicker is resulting from moving away from the green box and to the pop-up. The distance between the to causes the computer to close the pop-up because you've moved away from the green box, but just before the pop-up is completely closed, the mouse arrives at the pop-up, causing it to open again. Ideally, the two should intersect to allow the mouse to move directly from the box to the pop-up. Or, increase the delay before closing the pop-up.
闪烁不是因为悬停子项而是因为在关闭菜单时捕获了菜单。将菜单左上角移动
top: 0px; left: 0px;
解决了这个问题。此外,通过height: 500px 更改跨度的高度和宽度; width: 500px;
也解决了。为了使高度和宽度有效,请将跨度更改为 div。Flickering is not because of hovering the child but catching the menu when it is being closed. Moving the menu top left by
top: 0px; left: 0px;
solves it. Moreover changing height and width of the span byheight: 500px; width: 500px;
also solves. In order to be height and width to be effective change the span to div.http://jsfiddle.net/GNQyt/17/
这是另一个带有碰撞箱的解决方案。这个几乎被黑客攻击了,但我想你会从中有所了解:)
请记住这
是一种非法操作,因为你不应该将块元素包装到内联元素中。
http://jsfiddle.net/GNQyt/17/
Here's another solution with a hitbox. This one is pretty much hacked, but i think you will get a sense out of it :)
Please keep in mind that
is an illegal operation, since you shouldnt wrap block elements into inline elements.