简体   繁体   English

元素边框上的html鼠标悬停事件

[英]html mouseover event on element border

I am wondering whether it is possible to bind mouseover event to one of the HTML element border, say, the left border of a div. 我想知道是否可以将鼠标悬停事件绑定到HTML元素边框之一,例如div的左边框。

The div is a container for other complex html elements, and there are mouseover events attached for its sub elements. div是其他复杂html元素的容器,并且为其子元素附加了鼠标悬停事件。 Binding mouseover event to the whole container div itself is a method, however the user will not be able to distinguish whether he select the container or the sub elements. 将鼠标悬停事件绑定到整个容器div本身是一种方法,但是用户将无法区分他是选择容器还是子元素。

I want a very obvious method to indicate that the container can be selected, like highlighting the container when he mouseover the left border area. 我想要一个非常明显的方法来指示可以选择容器,例如当鼠标悬停在左边框区域时突出显示容器。

Or is there any other good way to solve the problem? 或者还有其他好办法解决问题吗?

Thank you. 谢谢。

Borders are not elements, and as such you cannot bind mouseenter events to them. 边框不是元素,因此您无法将mouseenter事件绑定到它们。 If you wanted this type of functionality, you would need to place a series of elements around the edges of the element (or at least next to your target edge), and bind to that. 如果您想要这种类型的功能,则需要在元素的边缘(或至少在目标边缘旁边)放置一系列元素,并绑定到该元素。

This particular approach was taken by Dropbox in their web-based upload feature. Dropbox在其基于Web的上传功能中采用了这种特殊方法。 When you drag a file from your desktop onto their page, you'll notice that div elements around the top, bottom, and sides all fade into view. 将文件从桌面拖到页面上时,您会注意到顶部,底部和侧面的div元素都会淡入视图。 This was accomplished with four div elements placed near the edges of the viewport. 这是通过在视口边缘附近放置四个div元素来实现的。

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

相关问题 如果父级有边框,当鼠标退出父级和子级时,如何避免来自父级元素的mouseover事件 - How to avoid the mouseover event from the parent element when the mouse is exiting both parent and child if the parent has a border 如何使用JavaScript中的mouseover事件使HTML边框更改颜色? - How do I make an HTML border change color with the mouseover event in JavaScript? 在鼠标悬停事件jQuery上显示边框的内容 - What to show border on mouseover event jquery 如何在鼠标悬停时在div元素周围创建边框 - How to create border around div element on mouseover HTML5 canvas Mouseover事件 - HTML5 canvas Mouseover event 由于我已将mouseover和mouseout事件附加到HTML中的每个元素,如何在几个HTML元素上阻止相同的事件? - Since I have attached mouseover and mouseout event to each and every element in HTML, How can I prevent same event on few HTML element? 鼠标悬停时html元素的CSS选择器 - CSS selector for html element on mouseover 鼠标悬停在其他元素上时元素上的jQuery事件 - jQuery event on element when mouseover on other element 如何使用 angular 中的 setAttribute 将鼠标悬停事件添加到动态生成的 html 元素 - How to add mouseover event to a dynamically generated html element by using setAttribute in angular 鼠标悬停事件上的多个元素,而不是单个元素 - Multiple elements on mouseover event instead of single element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM