4

为什么 jquery resizable() 没有将大小调整为分配给它的包含 ID 的全宽和高度。您可以在http://jsfiddle.net/C8YSU/6/尝试一下,看看我的意思。尝试调整创建的 div 的大小,它不会在父#container div 上调整为全宽和全高。这似乎是由draggable()功能引起的。

4

3 回答 3

8

Adding a relative position to the #container div fixed the problem.

于 2011-01-25T00:42:49.970 回答
3
<script type="text/javascript">
        $("button").click(function () {
            var elm = $('<div id="divId" class="adiv abs"></div>');
            elm.appendTo('#container').resizable({
                containment: "parent"
            });
        });
    </script>

更新

<script>
        $("button").click(function () {
            var elm = $('<div id="divId" class="adiv abs"></div>');
            elm.appendTo('#container').draggable({
                snap: true,
                containment: 'parent'
            }).resizable({
                maxWidth: 300,
                maxHeight: 300
            });
        });

</script>
于 2011-01-25T00:54:59.067 回答
0

It is a problem with adding draggable to it.

Try this example. Removed draggable, but added handles.

http://jsfiddle.net/C8YSU/7/

于 2011-01-25T00:35:58.023 回答