我有解决此问题的方法,但我在使用 html/javascript (jquery) 时注意到一些奇怪的行为。
我注意到将元素向右和向下移动超出包含元素的边界会调整包含元素的大小。例如,读者被定向到 http://jqueryui.com/demos/draggable/ .尝试将框拖动到包含框的右侧或下方。这种行为令人抓狂。
如何禁用这个烦人的属性?我的大部分元素都是 position: relative 因为按照它们的书写顺序放置它们根本不是很有用。这只是我注意到的事情,并希望得到一些推理。
最佳答案
你可以试试containment
:
Constrains dragging to within the bounds of the specified element or region. Possible string values: 'parent', 'document', 'window', [x1, y1, x2, y2].
$( ".selector" ).draggable({ containment: "parent" });
关于javascript - 静态大小的外部元素,尤其是在右侧和下方使用 .animate(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11255967/