拖动时的固定项目

此示例使用占位符上的类将其转换为一行,使其不占用任何空间。

HTML

<div id="sortable">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
</div>

JS

$("#sortable").sortable({
    placeholder: 'placeholder',
    helper: 'clone',
    start: function(event, ui){
        ui.item.show();
    }
});

CSS

#sortable div{
  background-color: #f00;
  width: 50px;
  height: 50px;
  margin: 10px;
  padding: 0px;
}
#sortable div.placeholder{
  height: 4px;
  margin: -7px 10px;
}