jquery 可调整大小游标帮助
我已经设置了一个可调整大小的 div:
$("mydiv").resizable();
现在,当您向右调整它的大小时,光标会离开实际调整大小的部分。因此,如果光标击中屏幕的一侧,如果您想将其变大,则必须松开鼠标并返回并重新开始调整其大小。我知道对于draggable,cursorAt 有一个选项可以告诉光标停留在该div 上。我查看了 jquery ui.com,但没有看到可调整大小的cursorAt。有没有办法在调整大小时将鼠标光标保持在可调整大小的部分上?
I have setup a div that is resizable:
$("mydiv").resizable();
Now when you go to resize it to the right the cursor goes off the the actual resize part. So if the cursor hits the side of the screen you have to let go of the mouse and go back and start resizing it again if you want to make it bigger. I know that with the draggable's there is an option for cursorAt that will tell the cursor to stay on that div. I looked at jquery ui.com but didnt see a cursorAt for the resizable. Is there a way to keep the mouse cursor on the resizable part while resizing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,我明白了,罪魁祸首似乎就是您所指出的:
“这是因为我正在调整大小的另一个 div 具有属性
margin:0 auto
”具有
0 auto
意味着左右边距会自动调整以平衡,从而使div
元素居中。我认为您不想以这种方式调整大小,因为在调整大小以保持居中时div
的位置会移动。我的建议是,删除保证金的
auto
设置。更新:
我在 resizble 演示页面 的 firebug 中运行了这个:
$("#ressized").css("margin","0 auto");
使用auto
margin 将框居中这是我所得到的屏幕截图:
拖动距离原始大小越远,调整大小光标就会远离框的角落。
然而,尽管“体验”感觉很奇怪,但它仍然有效。
Ah I see, the culprit seems to be what you pointed out:
"It is because the other div that I am resizing has the property
margin:0 auto
"Having
0 auto
means the left, right margin is automatically adjusted to balance out which will centralise thediv
element. I do not think you want to resize in that manner as the position of thediv
moves while you are resizing in order to stay centered.My suggestion, remove the
auto
setting for your margin.Update:
I ran this in firebug at the resizble demo page:
$("#resizable").css("margin","0 auto");
to center the box usingauto
marginHere's a screenshot of what I've got:
The resizing cursor moved away from the box's corner the more you drag away from the orginal size.
However it still work though the 'experience' feels odd.