Jquery UI 可排序占位符未显示在阻止列表中
我在 ul 中有一些项目显示为内联块。我可以使用 jquery ui 的可排序功能对它们进行排序,但占位符没有显示。
$(document).ready(function() {
$('#sortableList').sortable({
refreshPositions: true,
opacity: 0.6,
scroll: true,
containment: 'parent',
placeholder: 'placeholder',
tolerance: 'pointer'
}).disableSelection();
});
.sequencer {
height: 110px;
width: 600px;
overflow-y: hidden;
overflow-x: hidden;
}
.sequencer ul {
white-space: nowrap;
overflow-x: scroll;
overflow-y: hidden;
}
.sequencer li {
display: inline-block;
padding-right: 10px;
padding-left: 10px;
text-align: center;
}
.sequencer img {
display: block;
height: 50px;
}
.placeholder {
background: #f3f3f3;
visibility: visible;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.js"></script>
<div class='sequencer'>
<ul id='sortableList'>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage1</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage2</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage3</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage4</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage5</li>
</ul>
</div>
I have a few items in a ul being displayed as an inline-block. I'm able to sort them with jquery ui's sortable, but the placeholder is not showing up.
$(document).ready(function() {
$('#sortableList').sortable({
refreshPositions: true,
opacity: 0.6,
scroll: true,
containment: 'parent',
placeholder: 'placeholder',
tolerance: 'pointer'
}).disableSelection();
});
.sequencer {
height: 110px;
width: 600px;
overflow-y: hidden;
overflow-x: hidden;
}
.sequencer ul {
white-space: nowrap;
overflow-x: scroll;
overflow-y: hidden;
}
.sequencer li {
display: inline-block;
padding-right: 10px;
padding-left: 10px;
text-align: center;
}
.sequencer img {
display: block;
height: 50px;
}
.placeholder {
background: #f3f3f3;
visibility: visible;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.js"></script>
<div class='sequencer'>
<ul id='sortableList'>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage1</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage2</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage3</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage4</li>
<li>
<img src='http://images.wikia.com/reddithistory/images/1/10/3-rage-face.png' />rage5</li>
</ul>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您拖动的项目没有明确的高度,因此您应该使用该选项
无需手动指定占位符的尺寸。
JSFiddle
Since the items you're dragging doesn't have an explicit height, You should use the option
No need to manually specify dimensions for placeholder.
JSFiddle
如果您设置了
高度
和宽度
,您的占位符将可见。检查 jsfiddle 与您的代码: jsfiddle
Your placeholder will be visible if you set
height
andwidth
to it.Check jsfiddle with your code: jsfiddle
将高度宽度和不透明度添加到占位符中,然后它就可以正常工作
Add height width and opacity to your placeholder, then it will work fine