当我尝试从顶部调整元素的大小(即使看起来好像在调整大小)时,我注意到底部也被调整了大小。
HTML:
<div class="resizeme" style="background:yellow;">Resize me from the top</div>
JS
$(".resizeme").resizable({
handles: "n,s,e,w"
});
jsfiddle:
http://jsfiddle.net/mody5/4x3r8vsq/
我该如何纠正?
通过调整大小,您可以更改高度和宽度,而无需更改可调整大小元素中内容的放置或对齐方式。
因此,实际上可调整大小的元素的行为与预期的一样,没有参考点就显得很奇怪。可以将其想象为从您抓住的手柄上拉伸它,而当您抓住的边缘移动时,另一侧保持放置状态。
试试这个:
$(document).ready(function() {
$(".resizeme").resizable({
handles: "n,s,e,w"
});
});
.resizeme {
position: relative;
top:20px;
background: yellow;
padding: 6px;
height: 100px;
width: 200px;
}
#top {
position: fixed;
top: 28px;
background: red;
}
#bottom {
position: fixed;
bottom: 60px;
background: blue;
}
<link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<div class="resizeme">
</div>
<span id="top">Resize me from the top</span><span id="bottom">Resize me from the bottom</span>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句