是否可以使用jquery对话框设置位置和自动宽度?

时间:2017-04-10 06:14:01

标签: jquery dialog box

我想知道是否可以设置一个对话框位置,例如从左侧60px,然后100%到屏幕右侧60px。

Hereis an image to be more clear of what I'm trying to do.

    <button id="opener">Open Dialog</button>
<div id="dialog" title="Basic dialog">
    <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
    <p>
        <button id="opener2">Open a nested dialog</button>
    </p>
</div>
<div id="dialog2" title="Nested dialog">
    <p>I would like this particular box to be positioned from the left, while the rest of the box extends to the right side of the window.</p>
</div>

    $("#opener").click(function () {
    $("#dialog").dialog("open");
});
$("#dialog").dialog({
    autoOpen: false,
    modal: false,
    position: [0,63],
    width: 283,
    open: function (event, ui) {
        $(".ui-dialog #opener2").click(function () {
            $("#dialog2").dialog("open");
        });
    }
});
    var w = $(window).width();

$("#dialog2").dialog({
    autoOpen: false,
    modal: false,
    position: [294,63],

});

    .ui-widget-overlay {
    background: rgba(0,0,0,0.9);
}

1 个答案:

答案 0 :(得分:0)

首先让我知道您的源代码。 如果你使用bootstrap做这样的事情。

<div class="col-md-4">
Your basic dialog..
</div>

<div class="col-md-8">
Your nested dialog box..
</div>