如何在双击时停止突出显示 div 元素
我有一个带有背景图像的 div 元素,我想在双击它时停止在 div 元素上突出显示。有 CSS 属性吗?
I have this div element with a background image and I want to stop highlighting on the div element when double-clicking it. Is there a CSS property for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
下面的 CSS 阻止用户选择文本。实例:http://jsfiddle.net/hGTwu/20/
向下定位 IE9 并运行 Opera必须使用 HTML 属性
unselectable
来代替:The CSS below stops users from being able to select text. Live example: http://jsfiddle.net/hGTwu/20/
To target IE9 downwards and Opera the HTML attribute
unselectable
must be used instead:这对我有用
This works for me
我试图找到一种解决方案来阻止 Chrome 中的 div 突出显示,并转向了这篇文章。
但不幸的是,所有答案都没有解决我的问题。
经过大量在线研究后,我发现修复非常简单。不需要任何复杂的 CSS。只需将以下 CSS 添加到您的网页即可。这适用于笔记本电脑和移动屏幕。
注意:这适用于 Chrome 版本 44.0.2403.155 m。此外,当今所有主要浏览器都支持它,如以下网址所述: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-style
I was trying to find a solution to stopping div highlighting in Chrome, and turned to this post.
But, unfortunately, none of the answers solved my problem.
After a lot of online research, I found that the fix is something very simple. There is no need for any complex CSS. Just add the following CSS to your web page and you are all set. This works in laptops as well as mobile screens.
NOTE: This worked in Chrome Version 44.0.2403.155 m. Also, it is supported in all major browsers of today as explained at this url: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-style
我不是 CSS 专家,但我认为只要扩大受影响的元素数量,您就可以使用 tw16 的答案。例如,这可以防止在我的页面上的任何地方突出显示,而不影响任何其他类型的交互性:
第一行由 Paul Irish 提供(来自 http://adamschwartz.co/magic-of-css/chapters/1-the-box/)。
I'm no CSS expert, but I think you can use tw16's answer as long as you expand the number of elements affected. For instance, this prevents highlighting everywhere on my page without affecting any other kind of interactivity:
That first line is courtesy of Paul Irish (via http://adamschwartz.co/magic-of-css/chapters/1-the-box/).
定位所有 div 元素:
定位所有元素:
Target all div elements:
Target all elements:
禁用用户选择:
为所选元素设置背景透明:
disable user selecting:
set background transparent for selected element:
如果某个元素是可点击的,您可能希望将其设为按钮元素。
If an element is clickable, you might want to make it a button element.