使JQuery对话框内容的宽度和高度均为100%

我创建一个div,然后在对话框中打开它.我尝试了这个div的样式,以实现内容在两个方向上扩展到100%.

到目前为止我尝试了什么:
设置div样式

#content {
    width:auto !important;
    height:auto !important;
    background-color:red !important;
    display:block !important;
}

并设置认的div样式

$(div).dialog({ dialogClass: 'someStyle' });

.someStyle .ui-dialog-content 
{
    height:auto !important;
    display:block !important;
}

似乎什么都没有用!我重写宽度属性但不能覆盖高度属性.怎么破解这个?

我希望实现这样的目标:http://jsfiddle.net/S3FQv/

解决方法

您可以使用jQuery width和height属性获取视口的像素宽度,并将其作为样式应用于div

var w = $(window).width();
var h = $(window).height();

//Set up the dialog with the width and height set above.
$('#myDialog').dialog({
    title: 'My Dialog',height: h,width: w
});

看到这个小提琴:http://jsfiddle.net/URpmR/2/

如果用户更改浏览器的大小,您还应该添加一些额外的代码来重新执行该函数

$(window).resize(myFunction());

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...