我希望您能使用滚动条让用户从左到右对对象进行排序。
这些对象是带有HTML的盒子,包括一些文本,而不是像其他示例中的图片。
问题在于,当用户拖动其中一个对象时,所有其他对象都会在拖动期间向下移动。
以下是我的代码:
HTML:
我尝试了许多不同的设置,并将其中一些作为注释留下来。
最好的方法是在这里查看问题:http://jsfiddle.net/francispotter/gtKtE/
这些对象是带有HTML的盒子,包括一些文本,而不是像其他示例中的图片。
问题在于,当用户拖动其中一个对象时,所有其他对象都会在拖动期间向下移动。
以下是我的代码:
HTML:
<div id="parent" class="parent">
<div id="list" class="list">
<div class="item">A</div>
<div class="item">B</div>
<div class="item">C</div>
</div>
</div>
CSS:
.parent {
height:64px;
width:280px;
}
.list {
background-color:#d0d0d0;
white-space:nowrap;
overflow-x:scroll;
overflow-y:hidden;
/*text-align:left;*/
}
.item {
background-color:#404040;
height:40px;
width:100px;
margin:4px;
cursor:pointer;
display:inline-block;
/*float:left;*/
/*float:none;*/
/*clear:both;*/
}
.placeholder {
height:40px;
width:20px;
display:inline-block;
margin:4px;
}
Javascript:
$(function() {
$('#list').disableSelection().sortable({
scroll: true,
placeholder: 'placeholder',
//containment:'parent',
axis: 'x'
});
})
我尝试了许多不同的设置,并将其中一些作为注释留下来。
最好的方法是在这里查看问题:http://jsfiddle.net/francispotter/gtKtE/