javascript - 调整大小时,Jquery Resizable Div 宽度和高度变为 0

标签 javascript jquery css jquery-ui jquery-ui-resizable

我有这个代码:

<table>
    <tr>
        <td id="parent">
            <div id="child"></div>
        </td>
    </tr>
</table>

我的 JavaScript 代码:

$('#child' ).resizable({
    animate: true,
    helper: '.ui-resizable-helper',
    maxWidth: 500,
    maxHeight: 500,     
    aspectRatio: true
});

使用上面的代码,我的可调整大小的 div 按预期工作,但是当我添加 containment 选项时,divwidthheight 调整大小为 0,在任何方向调整大小时。

   $('#child' ).resizable({
        animate: true,
        helper: '.ui-resizable-helper',
        maxWidth: 500,
        maxHeight: 500,     
        aspectRatio: true,
        containment: '#parent'
    });

为什么会这样?是错误吗?

最佳答案

尝试添加这个 CSS:

#parent {
  width: 500px;
  height: 500px;
}

关于javascript - 调整大小时,Jquery Resizable Div 宽度和高度变为 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34487353/

相关文章:

javascript - React v16 hydrate 和 renderToNodeStream 对比 render 和 renderToString

javascript - 创建一个知道鼠标来自哪里的 div,包括高速鼠标边缘情况

jquery - touchstart PreventDefault in body = 无法聚焦输入

css - 如何使用CSS设置背景图片宽度?

javascript - Node.js 无法在另一个文件夹中找到文件

javascript - 如何设置 JQuery 数据表

javascript - onchange 输入值触发选择选项更改不起作用

html - CSS - 将 body 标签内的所有内容居中

javascript - 如何使用 iscroll javascript 实现滚动功能

javascript - ionic ionic 日期时间 : how to set default picker value