sortablejs_multi_list.html
· 1.4 KiB · HTML
Ham
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SortableJS 多清單範例</title>
<style>
.container {
display: flex;
gap: 20px;
}
.list {
list-style: none;
padding: 10px;
width: 200px;
min-height: 200px;
border: 2px dashed #ccc;
background: #f9f9f9;
border-radius: 5px;
}
.list-item {
padding: 10px;
margin: 5px;
background: #fff;
border: 1px solid #ddd;
cursor: grab;
text-align: center;
}
.list-item:hover {
background: #f0f0f0;
}
</style>
</head>
<body>
<h2>拖曳項目到不同清單</h2>
<div class="container">
<ul id="list1" class="list">
<li class="list-item">項目 A</li>
<li class="list-item">項目 B</li>
<li class="list-item">項目 C</li>
</ul>
<ul id="list2" class="list">
<li class="list-item">項目 X</li>
<li class="list-item">項目 Y</li>
</ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
<script>
new Sortable(document.getElementById('list1'), {
group: 'shared',
animation: 150
});
new Sortable(document.getElementById('list2'), {
group: 'shared',
animation: 150
});
</script>
</body>
</html>
| 1 | <!DOCTYPE html> |
| 2 | <html lang="zh-TW"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | <title>SortableJS 多清單範例</title> |
| 7 | <style> |
| 8 | .container { |
| 9 | display: flex; |
| 10 | gap: 20px; |
| 11 | } |
| 12 | .list { |
| 13 | list-style: none; |
| 14 | padding: 10px; |
| 15 | width: 200px; |
| 16 | min-height: 200px; |
| 17 | border: 2px dashed #ccc; |
| 18 | background: #f9f9f9; |
| 19 | border-radius: 5px; |
| 20 | } |
| 21 | .list-item { |
| 22 | padding: 10px; |
| 23 | margin: 5px; |
| 24 | background: #fff; |
| 25 | border: 1px solid #ddd; |
| 26 | cursor: grab; |
| 27 | text-align: center; |
| 28 | } |
| 29 | .list-item:hover { |
| 30 | background: #f0f0f0; |
| 31 | } |
| 32 | </style> |
| 33 | </head> |
| 34 | <body> |
| 35 | |
| 36 | <h2>拖曳項目到不同清單</h2> |
| 37 | |
| 38 | <div class="container"> |
| 39 | <ul id="list1" class="list"> |
| 40 | <li class="list-item">項目 A</li> |
| 41 | <li class="list-item">項目 B</li> |
| 42 | <li class="list-item">項目 C</li> |
| 43 | </ul> |
| 44 | |
| 45 | <ul id="list2" class="list"> |
| 46 | <li class="list-item">項目 X</li> |
| 47 | <li class="list-item">項目 Y</li> |
| 48 | </ul> |
| 49 | </div> |
| 50 | |
| 51 | <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script> |
| 52 | <script> |
| 53 | new Sortable(document.getElementById('list1'), { |
| 54 | group: 'shared', |
| 55 | animation: 150 |
| 56 | }); |
| 57 | |
| 58 | new Sortable(document.getElementById('list2'), { |
| 59 | group: 'shared', |
| 60 | animation: 150 |
| 61 | }); |
| 62 | </script> |
| 63 | |
| 64 | </body> |
| 65 | </html> |
| 66 |