ZeroClipboard复杂的CSS问题
我有图像列表,将鼠标悬停在其下方会显示选项框,其中嵌入了可供复制的代码输入框。现在我在它上面实现了zeroclipboard,为了使复制功能在单击时起作用,所以当我将鼠标悬停在图像上时,它会正确显示选项框,但是当我用鼠标单击输入框来复制代码时,该选项会出现关闭,认为它不再在选项 div 中,因为 Zeroclipboard 上面有 div,所以鼠标放在它上面,它就会关闭。
所以解决方案是在选项 div 内创建该 div,该选项一直在处理,但现在 Zeroclipboard div 样式显示错误,我不知道如何修复它。
以下是zeroclipboar的样式,我不知道要在其上设置什么样式,因此它位于输入框上方,因此我可以单击它,因此它可以正常工作,就像通常一样。
on line 107 in zeroclipboard.js
var style = this.div.style;
style.position = 'absolute';
style.left = '' + box.left + 'px';
style.top = '' + box.top + 'px';
style.width = '' + box.width + 'px';
style.height = '' + box.height + 'px';
style.zIndex = zIndex;
i have list of images and on mouse over there is option box shows under it, which has embeded code input box to copy from. now i implemented zeroclipboard on it, for making copy function work on click, so when i do mouse over on image, it shows the option box properly, but when i take mouse to click on the input box to copy the code, the option gets closed, thinking its not in option div anymore, because zeroclipboard has div on top of it so mouse goes on it and it gets closed.
so solution was to create that div inside the option div, which has been taking care of, but now zeroclipboard div style is showing wrong and i dont know how to fix it.
following are the style for zeroclipboar, i dont know what style to set on it, so its above the input box, so i can click on it and so it works fine like it usally does.
on line 107 in zeroclipboard.js
var style = this.div.style;
style.position = 'absolute';
style.left = '' + box.left + 'px';
style.top = '' + box.top + 'px';
style.width = '' + box.width + 'px';
style.height = '' + box.height + 'px';
style.zIndex = zIndex;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道你的代码是什么样的,但是当你使用悬停或鼠标悬停/鼠标移出显示选项框时,只需包含零剪贴板 div...类似这样的内容(我相信这是要使用的正确对象 ID):
I don't know what your code looks like, but when you display your options box using hover or mouseover/mouseout, just include the zero clipboard div... something like this (I believe that is the correct object ID to use):
当我使用零剪贴板时,我注意到当我不需要它时最好将其移动到负的左侧位置。例如:
我不太明白你的问题,但动态地将其从引起问题的地方移开可能是解决你的问题的一种方法。
When I used zero clipboard, I noticed that it was best to move it to a negative left position when I didn't need it. Such as:
I don't quite understand your question, but dynamically moving it away from where it is causing you problems might be a way to solve your problem.
仅供您参考:
我的方法使用数据属性来激活复制功能。
除此之外,它还在根元素上设置悬停和活动类。
用法:
HTML:
JavaScript:
Just for your interest:
My approach uses data attributes to activate the copy functionality.
In addition to that it sets hover&active classes on the root Element.
Usage:
HTML:
Javascript: