jQuery UI Sortable:拖动的元素消失
我设置了
.sortable()
,容器中有一些元素。当我拖动内部元素时,打算将该元素与其他元素一起排序,一旦将其拖出容器,就看不到。
但当我把它放入占位符时,它又可以看到了。 在线案例在这里。
有人以前遇到过这个问题吗?或者任何人都可以帮助我解决这个问题吗?
谢谢
I set the <div class="container">
.sortable()
, and there are some elements in the container.
When I drag the inner element, intend to sort the element with the others, once the dragged one out the container, it can not be seen.
But when I drop it into place holder, it could be seen again. Online case is here.
Anyone have met the problem before? Or anyone can help me with the problem?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将
overflow:hidden;
放到.container
上,它就会起作用。问题是,在拖动过程中,您将.container
的子级移动到.container
元素之外,您已经告诉浏览器隐藏任何溢出。在拖动期间重新强制溢出,并且浏览器正在执行您告诉它执行的操作。一般建议:保留
overflow
除非您知道它的作用以及为什么需要使用它。Drop the
overflow: hidden;
on.container
and it will work. The problem is that during the drag you're moving a child of.container
outside of the.container
element, you've told the browser to hide any overflow while you're forcing an overflow during the drag and the browser is doing what you told it to do.General advice: leave
overflow
alone unless you know what it does and why you need to use it.技巧是将帮助程序设置为
'clone'
并使用临时交换列表进行拖动..代码的修改版本 此处the trick is to set helper to
'clone'
and use a temporary swaplist for the drag.. modified version of your code here我拖动的项目在垂直列表中消失,我发现使用溢出-y:隐藏而不是溢出:隐藏对我有用。即仅针对 y 轴。
My dragged items were disappearing in a vertical list and I found that using overflow-y: hidden instead of overflow:hidden worked for me. i.e. only target the y axis.
问题很可能是由于以下原因造成的:
.container{ margin:0 20px;位置:绝对;顶部:0;高度:100%;宽度:280px;溢出:隐藏;}
。如果您设置了overflow:auto,它会显示带有滚动条的包装器div,您可以查看您的portlet。
most probably the problem is due to this:
.container{ margin:0 20px; position:absolute;top:0;height:100%;width:280px;overflow:hidden;}
.If you set
overflow:auto
it shows the wrapper div with scrollbar and you can view your portlet.