子节点出不了父div [英] Child nodes not go out of the parent div
问题描述
我有这个div
:
<div id="composition_area" style="width: 700px; height: 600px; float:left; border:solid 2px"><div id="a" class="a window" style="width: 80px; height: 80px; border: solid 1px" contenteditable="true">foo</div>
并在其中使用 id="composition_area"
我添加带有 jsplumb
的节点.在这个例子中,我有一个带有 id="a"
的节点.所有节点都是可拖动的,用户可以将 div 移动到他想要的任何位置.但我希望不走出父div.我该怎么做?
看文档 http://jsplumbtoolkit.com/doc/home#dragging
<块引用>一个常见的要求是能够控制其中的区域可以拖动元素.对于 jQuery,这就像提供一个简单的遏制参数:
jsPlumb.draggable($("someSelector"), { contains:"parent" });
试试这个:
jsPlumb.draggable($("#composition_area"), {收容:父母"});
I have this div
:
<div id="composition_area" style="width: 700px; height: 600px; float:left; border: solid 2px">
<div id="a" class="a window" style="width: 80px; height: 80px; border: solid 1px" contenteditable="true">foo</div>
</div>
and inside of this with id="composition_area"
I add nodes with the jsplumb
. In this example I have a node with id="a"
. All the nodes are draggable and the user can move the divs anywhere he wants. But I want not to go out of the parent div. How can I do that?
Look at the doc http://jsplumbtoolkit.com/doc/home#dragging
A common request is for the ability to contain the area within which an element may be dragged. For jQuery this is as simple as providing a containment parameter:
jsPlumb.draggable($("someSelector"), { containment:"parent" });
try this :
jsPlumb.draggable($("#composition_area"), {
containment:"parent"
});
这篇关于子节点出不了父div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!