jQuery UI sortable()-listitem在Safari和Chrome中跳到顶部 [英] jQuery UI sortable() - listitem jumps to top in Safari and Chrome
问题描述
我在页面底部有一个可排序的无序列表,在Firefox中效果很好.但是,在Safari/Chrome浏览器中,当我要拖动时,抓取的列表项会立即跳到页面顶部,就像UL在窗口顶部一样.有人知道这是怎么回事吗?
I have a sortable unordered list on the bottom of my page, which works perfect in Firefox. However, in Safari/Chrome the grabbed listitem jumps instantly to the top of the page when I want to drag it, like the UL is on top of the window. Does anyone know what's going on here?
谢谢. Lex.
这是代码:
HTML(和PHP):
HTML (and PHP):
<ul id="list">
<?
foreach($downloads as $download)
{
echo "<li class='downloads'><a rel='".$download->id."' href='".$base_url."downloads/".$download->id."'>".$download->title."</a></li>";
}
?>
</ul>
CSS:
ul#list {
padding: 10px 0;
display: block;
}
ul#list li {
background: #fff;
padding: 10px;
color: #bc1e2c;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
font-weight: bold;
margin: 10px 0;
display: block;
}
ul#list li:hover {
background: #212121;
color: #fff;
cursor: move;
}
JS:
$(".alter-content ul#list").sortable({
update : saveSortorder,
containment: 'parent'
});
推荐答案
我遇到了同样的问题.它在Firefox中运行良好,但在Safari和Chrome中不断发展.
我终于通过在CSS的未排序列表中添加overflow: auto;
来解决了这个问题.
I had the same problem. It worked well in Firefox but kept jumping in Safari and Chrome.
I finally fixed it by adding overflow: auto;
to the unsorted list in my CSS.
我什至不必指定UL的高度.
I didn't even have to specify the height of the UL.
这篇关于jQuery UI sortable()-listitem在Safari和Chrome中跳到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!