尝试this代码:
HTML
<div class="draggable_container">
<div id="draggable_1" class="draggable">
<div class="exp"><!-- --></div>
</div>
</div>
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'
});
现在,如果您单击“可拖动”框并上下移动鼠标,它将移动到容器高度。
但是,如果您用鼠标单击此框,然后滚动页面(使用鼠标滚轮...或将光标移动到底部,而不释放鼠标),则该框将覆盖容器。这很糟糕。
这是一个常见的错误吗?我该如何解决这个问题?
最佳答案
我不知道这是否是一个错误,但我通过将 overflow:auto
添加到 .draggable_container
css 类来解决它。在这里查看:http://jsfiddle.net/QhVNr/2/
关于jQuery 可拖动 : the draggable box go over the container - bug?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8656653/