How to stop list items when jumping when using inline block with drag and drop jQuery?

The joy of the jQuery drag-and-drop API just opened up, but I want to display my list using the built-in block. This makes the list items jump when you drag them, does anyone know how to fix this?

The code I use is:

$(function() { $( "#sortable1, #sortable2" ).sortable({ connectWith: ".connectedSortable" }).disableSelection(); });​ 

http://jsfiddle.net/VVaqu/

+4
source share
2 answers

Demo screenshot

Just add: float:left; to your li elements

 #sortable1 li, #sortable2 li { float:left; /*other styles...*/ } 
+3
source

Another solution if you cannot use float:

 #sortable1 li, #sortable2 li{ display: inline-block; vertical-align: top; } 

Vertical alignment is important: top.

+6
source

Source: https://habr.com/ru/post/1447621/


All Articles