JQuery UI 计算对话框内内容的大小以避免对话框中出现滚动条

发布于 2024-12-06 02:22:41 字数 906 浏览 4 评论 0原文

我将一些内容放入 JQuery UI 对话框中。 HTML 如下:

<div id="dialog">
  <div id="content">

    <div id="scrollable">

      <div id="data">
        <ul>
        <li/>
        <li/>
         ....
       </ul>
      </div>

    </div>

    <div id="footer">
    </div>
  </div>
</div>

JQuery 代码如下:

$('#dialog').dialog({
  width : 500,
  height: 300
})

如您所见,对我来说重要的大小是主容器(对话框)的大小。我希望内容位于对话框内,而对话框中没有滚动条。内容有两部分,数据本身始终具有垂直滚动条和始终可见的页脚(这部分已经已解决) 解决方案应该调整内容 div 的大小。我尝试了几次计算,考虑到对话框内的可用高度是:

var height=$('#dialog').height()-$('.ui-dialog-titlebar').height();
var dataHeight = height-$('#footer').height();

I'm putting some content inside a JQuery UI dialog. The HTML is as follows:

<div id="dialog">
  <div id="content">

    <div id="scrollable">

      <div id="data">
        <ul>
        <li/>
        <li/>
         ....
       </ul>
      </div>

    </div>

    <div id="footer">
    </div>
  </div>
</div>

And the JQuery code is sth like:

$('#dialog').dialog({
  width : 500,
  height: 300
})

As you see, the sizing that is important to me is the sizing of the main container, the dialog. I want the content to feet inside the dialog without scrollbars in the dialog. The content has two pieces, the data itself that always has a vertical scroll bar and a footer that is always visible (this part has already been solved)
The solution should resize the content div. I have tried several calculations taking into account that the available height inside the dialog is:

var height=$('#dialog').height()-$('.ui-dialog-titlebar').height();
var dataHeight = height-$('#footer').height();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文