当占位符高度小于元素高度时,jQuery可排序的问题

时间:2019-08-08 18:31:10

标签: javascript jquery html css

我有一个jQuery sortable,其中sortable元素具有不同的高度,但是占位符具有固定的高度。拖动时,如果元素比占位符高,它将放回到可排序对象上,直到光标低于原始元素的高度为止。

以下是显示问题的小提琴:http://jsfiddle.net/Ly35fvow/2/

这是我正在使用的代码:

$(function() {
  $('.content1').sortable();
});
.ui-sortable-placeholder {
  height: 20px;
  background: #FF0;
  display: block;
  visibility: visible!important;
}
<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<body>
  <div class="content1" style="width:100px;float:left">
    <div style='height:200px;background: #ddd'>1</div>
    <div style="height:50px: background: #CCC">2</div>
    <div style="height:40px; background: #999">3</div>
  </div>
  <div class="content2" style="width:200px;float:left">
    <div style='height:200px;border-bottom:1px dashed #999;vertical-align:bottom;display:table-cell'>
      Cursor must pass here
    </div>
  </div>

也许某人更了解可排序会知道为什么会发生这种情况以及如何解决它。

0 个答案:

没有答案
相关问题