如何让鼠标悬停时消失,而鼠标移动时不会闪烁? [英] How to make a div disappear on hover without it flickering when the mouse moves?

查看:405
本文介绍了如何让鼠标悬停时消失,而鼠标移动时不会闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在:hover css上看到了提示 display:none 的答案。但是,这使得当鼠标移动时div闪烁。

I've seen answers suggesting just display:none on the :hover css. But that makes the div flicker when the mouse is moving.

编辑:添加 jsfiddle

推荐答案

display:none 该元素脱离渲染树,因此立即丢失:hover 状态,然后再次出现并再次获得:hover 消失,再现等等。

display:none will take the element out of the render tree, so it loses :hover state immediately, then reappears and gets :hover again, disappears, reappears, etc...

您需要的是:

What you need is:

#elem { opacity:0; filter:alpha(opacity=0); }

它会将空白留空,所以不会出现闪烁。 Demo 你已更新

It will leave the place empty, so no flickering will appear. (Demo or yours updated)

这篇关于如何让鼠标悬停时消失,而鼠标移动时不会闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆