问题是当你离开这个区块的时候。向下和向右-滚动显示。当你往左走再往上走--什么都没有。并且它是必需的(可以运行和检查下面的代码)
$(function () {
$("#draggable3").draggable({});
});.generic-container {
height: 95vh;
width: 100vh;
overflow: scroll;
background-color: #aaa;
position: relative;
}
#draggable3{
height: 40vh;
width: 40vh;
background-color: #fff;
position: absolute;
left: 28%;
top: 28%;
}<html>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
<div class="generic-container">
<div id='draggable3' class="draggable">
</div>
</div>
</body>
</html>
限制参数的移动- "containment:'parent'“它不适合我
发布于 2017-04-02 22:52:34
添加scroll: false选项并从您的css中删除overflow: scroll;。
$(function() {
$("#draggable3").draggable({
containment: ".generic-container",
scroll: false
});
});.generic-container {
height: 95vh;
width: 100vh;
background-color: #aaa;
position: relative;
}
#draggable3 {
height: 40vh;
width: 40vh;
background-color: #fff;
position: absolute;
left: 28%;
top: 28%;
}<html>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
<div class="generic-container">
<div id='draggable3' class="draggable">
</div>
</div>
</body>
</html>
https://stackoverflow.com/questions/43169657
复制相似问题