简体   繁体   English

如何阻止jQuery UI对话框被压扁?

[英]How can I stop jQuery UI dialogs from getting squashed?

I have a fairly simple div element which I want to turn into a popup via jQuery UI. 我有一个相当简单的div元素,我想通过jQuery UI变成一个弹出窗口。 The HTML is basically HTML基本上是

<div id="login_form">
     <table> ... </table>
</div>

Without any jQuery involvement, it renders fairly naturally like this (the green background comes from the div and fits around its contents): 无需任何jQuery的参与,它就可以像这样自然地渲染(绿色背景来自div并适合其内容):

在此处输入图片说明

When I make it into a popup with this code: 当我使用以下代码将其弹出时:

 $(document).ready(function()
{
    $("#login_form") .dialog (
    {
        autoOpen: false
    });

    $("#login_or_sign_up") .click (function()
    {
        $("#login_form") .dialog ("open");
    });
});

It renders like this. 它像这样渲染。

在此处输入图片说明

Yuck. uck

I'm fairly sure the reason is simply that I haven't included the jQuery UI CSS files. 我相当确定,原因仅仅是我没有包括jQuery UI CSS文件。 I don't want to include the jQuery UI CSS files. 我不想包含jQuery UI CSS文件。

By inspecting the popup I notice that jQuery has created another div which surrounds the one I provided, and this is styled to have a width of 300px. 通过检查弹出窗口,我注意到jQuery创建了另一个div,该div围绕着我提供的div,其样式设置为300px的宽度。 I expect this is the problem -- jQuery UI has picked a size which is too small and the inner elements are not reducing themselves to fit. 我希望这是问题所在-jQuery UI选择的尺寸太小,内部元素不会缩小以适合自己。

Can I make jQuery dialog-ify my div without shrinking it? 我可以在不缩小div的情况下使jQuery对话框化吗?

If not, I can probably work around this by adding width:100% styles to the inner elements individually. 如果没有,我可以通过分别向内部元素添加width:100%样式来解决此问题。 In that case, is there a general workaround which will not require me to alter any of the inner elements? 在那种情况下, 是否有一个通用的解决方法不需要我更改任何内部元素?

.dialog({ width: 'auto' })起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM