javascript - 静态大小的外部元素,尤其是在右侧和下方使用 .animate()

标签 javascript jquery html css

我有解决此问题的方法,但我在使用 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/

相关文章:

javascript - 在 Python 中解析 JavaScript Web 应用程序的选项

javascript - JQuery 函数中的 For 循环

javascript - 在 HTML 中加载通用页脚

javascript - 将 javascript 中的函数作为全局函数调用

jquery - 添加 d3js 图表时三列布局中断

javascript - 无法从 Javascript 代码中删除空格

javascript - 如何使图像弹出?

javascript - 迭代数组对象

javascript - RxJS:可编程定时器

javascript - 检查变量是否为字符串的简单方法?