jQuery:相对于视口重新定位

jQuery:相对于视口重新定位,jquery,Jquery,将div拖动到显示滚动并调整大小时,它会忘记其实际位置,并相对于视口重新定位。如何保持其实际位置 <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css"/> <s

将div拖动到显示滚动并调整大小时,它会忘记其实际位置,并相对于视口重新定位。如何保持其实际位置

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/base/jquery-ui.css"/> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.js" type="text/javascript"></script> 
<script>
(function($){$(document).ready(function(){
    $('#theDiv').draggable().resizable();
})})(jQuery);   
</script>
</head>
<body>
    <div id="container" style="position:relative;width:600px;height:600px;border:solid 1px #000;overflow:auto;">
        <div id="theDiv" style="width:200px;height:200px;border:solid 1px #000;"></div>
    </div>
</body>
</html>

(函数($){$(文档).ready(函数(){
$('#theDiv').draggable().resizeable();
})})(jQuery);
你试过这个吗

您可以计算位置并传递到scrolltop

$("#divid").scrollTop(300); // 300 is just a sample