Sortable - When dragging a sortable item to a new location, other items will make room for the that item


SUBMITTED BY: jlolk3r

DATE: Jan. 19, 2016, 1:31 a.m.

FORMAT: HTML

SIZE: 1.3 kB

HITS: 1138

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>jQuery UI Sortable - Drop placeholder</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  8. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="/resources/demos/style.css">
  10. <style>
  11. #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
  12. #sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; height: 1.5em; }
  13. html>body #sortable li { height: 1.5em; line-height: 1.2em; }
  14. .ui-state-highlight { height: 1.5em; line-height: 1.2em; }
  15. </style>
  16. <script>
  17. $(function() {
  18. $( "#sortable" ).sortable({
  19. placeholder: "ui-state-highlight"
  20. });
  21. $( "#sortable" ).disableSelection();
  22. });
  23. </script>
  24. </head>
  25. <body>
  26. <ul id="sortable">
  27. <li class="ui-state-default">Item 1</li>
  28. <li class="ui-state-default">Item 2</li>
  29. <li class="ui-state-default">Item 3</li>
  30. <li class="ui-state-default">Item 4</li>
  31. <li class="ui-state-default">Item 5</li>
  32. <li class="ui-state-default">Item 6</li>
  33. <li class="ui-state-default">Item 7</li>
  34. </ul>
  35. </body>
  36. </html>

comments powered by Disqus