设置对话框的最大高度,然后允许滚动 [英] Setting max height of a dialog, then allow scrolling

查看:99
本文介绍了设置对话框的最大高度,然后允许滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎不明白如何正确设置jQuery UI对话框的高度.

I can't seem to understand how to set the height correctly for the jquery ui dialog.

我希望它可以显示存在的内容的高度,但是如果它超过400像素,那么我想要一个滚动条.

I want it to display the height to however much content is present, but if it exceeds 400 pixels, then I want a scroll bar.

因此,如果内容的高度为200像素,则对话框的高度应为200像素.

So, if the content has 200 pixels in height, then the dialog should have a height of 200 pixels.

如果内容的高度大于400像素,则对话框不应扩展到400像素以上,并且滚动条应可见.

If the content has a height larger than 400 pixels, then the dialog shouldn't expand past 400 pixels and a scroll bar should be visible.

我到目前为止有这个:

$("#popup").dialog({
            modal: true,
            autoOpen: false

});

推荐答案

$("#popup").dialog({
            modal: true,
            autoOpen: false
});

css

#popup {
 border: 1px solid #ccc;
 border-radius: 4px;
 padding: 10px;
 overflow: auto;
 max-height: 300px;   
}​

工作小提琴

编辑:更新了小提琴并调整了代码,使其可以正常工作.不知道为什么,通过jQuery UI对话框maxHeight似乎没有做应做的事情.我刚刚将最大高度部分添加到CSS中,一切都很好,很花哨.

Edit Updated fiddle and adjusted code so it would work. Not sure why, by the jQuery UI dialog maxHeight doesn't seem to be doing what it should. I just added the max height part to the CSS and all was fine and dandy.

这篇关于设置对话框的最大高度,然后允许滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆