简体   繁体   English

将DIV拖放到单元格中的任何位置

[英]Drag and Drop DIV to any position within a cell

I'm using the REDIPS Drag and Drop JQuery PlugIN , that allows me to create draggable content that snaps to a defined table and its cells. 我正在使用REDIPS拖放JQuery PlugIN ,它允许我创建可拖动的内容,该内容可捕捉到已定义的表及其单元格。 However I need to change a bit in such a way that it allows me to drop an element anywhere in a cell, rather than just placing it by default at the end or the beginning. 但是,我需要进行一些更改,使它可以将元素拖放到单元格中的任何位置,而不是默认将其放置在末尾或开始处。

So I still need to functionality where it "snaps content to a grid" but I need it to have any "left margin" within the dropped cell. 因此,我仍然需要功能,使其“将内容捕捉到网格”,但是我需要它在放置的单元格内具有任何“左边界”。 Once the div is dropped in a cell i would like it get its left margin or offset from the parent cell. 一旦将div放到单元格中,我希望它获得其左边界或与父单元格的偏移量。

Link to fiddle 链接到小提琴

var marginLeftAfterDrop = $("#" + divID).position.left;

I can see that you are using REDIPS for the draggable feature but I highly suggest to use the plugin made by Jquery through this link . 我可以看到您正在将REDIPS用于可拖动功能,但我强烈建议通过此链接使用Jquery制作的插件。

It is highly customizable and extendable according to your need. 根据您的需要,它是高度可定制和可扩展的。 Moreover, it is highly supported by the community and plenty of developers are using it. 而且,它得到了社区的高度支持,许多开发人员正在使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM