jQuery 如何在jquery中创建具有固定高度的可滚动对话框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6570375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:04:01  来源:igfitidea点击:

How to create scrollable dialog box with fixed height in jquery?

jqueryhtml

提问by koti

I requesting some data using jquery ajax function.i have to display requested data in jquery scrollable dialog how can i do that. Here i am using code.for requesting data.

我使用 jquery ajax 函数请求一些数据。我必须在 jquery 可滚动对话框中显示请求的数据,我该怎么做。这里我使用 code.for 请求数据。

$('#load').show();
        $.ajax({
            type: "POST",
            url: "push/push_notify.php",
            data: "pushmessage="+message+"&iphone="+iphone+"&android="+android+"&blackberry="+blackberry,

            success: function(e){
                $('#load').hide();
                var response =e;

               $("#showtable").fadeOut('slow').load("alerttable.php").fadeIn('slow');
            }
        });
       return false;

回答by Matyas

You can use a dialog from jQuery UIand the container divelement should have a fixed width & height and overflow set to scroll(scrollbars always appear) or auto(scrollbars appear when needed) .

您可以使用jQuery UI 中的对话框,并且容器div元素应具有固定的宽度和高度,并且溢出设置为scroll(scrollbars always come) 或auto(scrollbars 在需要时出现) 。

CSS of the div:

div 的 CSS:

#result-dialog{
    height: 300px;
    overflow: auto; /* Or scroll, depending on your needs*/
    width: 300px;
}

EDIT: Here it isa working example of a jquery dialogwith scrollable content. For more properties and styles of the dialogbox you should check out its page.

编辑:这是一个带有可滚动内容的jquery 对话框的工作示例。有关对话框的更多属性和样式,您应该查看其页面

In your html you should include:

在您的 html 中,您应该包括:

jQuery, jQuery UI, and jQuery UI CSS(these are hotlinks from Google's CDN - if you wish you can download these for yourself from jquery's home page)

jQueryjQuery UIjQuery UI CSS(这些是来自 Google CDN 的热链接 - 如果您愿意,可以从 jquery 的主页上自行下载这些链接)

回答by chhameed

Are you want this css property ?

你想要这个 css 属性吗?

Scrollable div

可滚动的 div

you must set the overflow and height width of the specific div

您必须设置特定 div 的溢出和高度宽度