你好,我在使用jQuery进行响应式缩放时遇到了问题。我有动态的div,希望将它们移动到另一个div中。当屏幕尺寸发生变化时,我的divs宽度、高度和位置保持不变。如何解决这个问题?我希望在屏幕大小发生变化时,divs的大小也随之改变并保持原来的位置。我考虑使用$(window).resize(function(){});,但是具体怎么实现呢?有人可以帮助我吗?
$('.box').each(function() { $('.box').draggable({containment: '#boxid'});});
$('.box').each(function() { $('.box').resizable();});
#boxid {
height: 750px;
border: 5px dotted #292929;
}
.box {
background:rgb(107, 193, 243);
cursor:move;
position:absolute;
}
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.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>
<div class="row">
<div id="boxid" class="col-xs-12">
<!-- hier die Position änder -->
</div>
</div>
<!--here I start the foreach -->
<div id="id" class="box" style="top:50px; left:50px; width:50px; height:50px;">
<p id="top"></p>
<p id="left"></p>
<p id="height"></p>
<p id="width"></p>
</div>
<div id="id" class="box" style="top:50px; left:50px; width:50px; height:50px;">
<p id="top"></p>
<p id="left"></p>
<p id="height"></p>
<p id="width"></p>
</div>
<!--here I end the foreach -->
![enter image description here](https://istack.dev59.com/auuv7.gif)