【问题标题】:Jquery UI DIalog margin too far to the rightJquery UI Dialog 边距太靠右
【发布时间】:2018-06-30 02:57:13
【问题描述】:

我有一个在表单提交时弹出的对话框。如果内容的宽度很小,它看起来很好,但是,随着文本的增长,对话框的左边距右边太远了。无论其中内容的大小如何,我都需要它始终处于中心位置。

标记:

<div id="dialog_confirm">
    <p style="font-size:20px; color:white;"></p>
</div>

jquery:

$('#dialog_confirm').dialog({
        autoOpen: false,
        modal: true,
        draggable: false,
        resizable: false,
        width: "auto",
        show: {
            effect: "blind",
            duration: 500
        },
        buttons: {
            'Confirm': {
                text: 'Confirm',
                id: 'confirm_button',
                click: function () {
                    $(this).dialog('close');
                }
            },
            'Cancel': {
                text: 'Cancel',
                id: 'cancel_button',
                click: function () {
                    $(this).dialog('close');
                }
            }
        }
    });

“宽度:自动”部分使内容适合对话框小部件,但我怎样才能使其始终位于较长文本的中心?

【问题讨论】:

    标签: jquery jquery-ui-dialog


    【解决方案1】:

    好的,我明白了。在我的 CSS 中:

    #dialog_confirm, .ui-dialog{margin-left: -15%;}
    

    我刚刚选择了一个任意数字进行测试,它似乎有效。如果有人有更好的解决方案,请随时加入。目前,这是可行的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多