[英]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
元素来实现的。
do you want like this 你想这样吗?
http://jsfiddle.net/GBpcg/ http://jsfiddle.net/GBpcg/
EDIT : http://jsfiddle.net/GBpcg/2/ 编辑: http : //jsfiddle.net/GBpcg/2/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.