我正在构建一个UI,其中我需要有两个或更多的可调整大小和可拖动的DIVs。我面临的问题是,当你调整一个div的大小时,原来在它下面的所有其他div都在移动(改变它们的位置)。请看https://jsfiddle.net/2f8g93nn/4/,我在这里写了一个例子来说明我的意思。在该示例中,如果将第二个div移动到右侧并调整第一个div的大小,则第二个div的位置将发生变化。
Jsfiddle.net中的HTML:
<!doctype html>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div class="Element" id = "FirstDiv" class="ui-widget-content">
<p>First DIV</p>
</div>
<div class="Element" id = "SecondDiv" class="ui-widget-content">
<p>Second DIV</p>
</div>
Jsfiddle.net中的Javascript:
$(function() {
$( ".Element" ).draggable();
$( ".Element" ).resizable();
});
Jsfiddle.net中的CSS:
.Element {
width: 150px;
height: 150px;
padding: 0.5em;
border:1px solid black;
}
发布于 2015-05-07 07:43:47
为了我的意见,让事情变得简单,你为什么不用标签.
以下是演示代码:https://jsfiddle.net/SeokKuan/2f8g93nn/8/
<textarea style="height: 100px;" placeholder="First Content"></textarea><br>
<textarea class="form-control" style="height: 100px;" placeholder="Second Content"></textarea>
nn/8/
发布于 2015-05-07 07:32:51
对于应该独立放置在页面中的元素,您应该使用position: absolute;
。
发布于 2015-05-07 07:42:30
https://stackoverflow.com/questions/30094425
复制相似问题