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
How to create scrollable dialog box with fixed height in jquery?
提问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 div
element 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)
jQuery、jQuery UI和jQuery UI CSS(这些是来自 Google CDN 的热链接 - 如果您愿意,可以从 jquery 的主页上自行下载这些链接)
回答by chhameed
Are you want this css property ?
你想要这个 css 属性吗?
you must set the overflow and height width of the specific div
您必须设置特定 div 的溢出和高度宽度