jQuery draggable:可拖动的盒子越过容器 – bug?
试试这段代码:
HTML
CSS
html { height:3000px; } .draggable_container { height:300px; background-color:red; width:140px; } .draggable { height:60px; width:130px; cursor:pointer; border:5px solid #000000; background-color:#ffffff; }
jQuery的
$(".draggable").draggable({ axis: "y", containment: 'parent' });
现在,如果您单击“可拖动”框并上下移动鼠标,它将移动到容器高度。
但是,如果用鼠标单击此框,然后滚动页面(使用鼠标滚轮…或将光标移动到底部,而不释放鼠标),框就会越过容器。 这很糟糕。
这是一个常见的bug吗? 我该如何解决这个问题呢?
我不知道这是不是一个bug,但是我通过在.draggable_container
css类中添加overflow:auto
来解决它。 在这里看到: http : //jsfiddle.net/QhVNr/2/