Setting max height of a dialog, then allow scrolling

老子叫甜甜 提交于 2019-12-07 07:36:28

问题


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

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.

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

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.

I have this so far:

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

});

回答1:


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

css

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

Working fiddle

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.



来源:https://stackoverflow.com/questions/11193455/setting-max-height-of-a-dialog-then-allow-scrolling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!