Position a jQuery UI Dialog

The Dialog widget's position option uses jQuery UI Position. Define which point on the dialog (my) should align with which point on the target (at), and choose the target with of.

PropertyPurpose
myThe point on the dialog to align, such as left top, center, or right bottom.
atThe point on the target to align with.
ofThe target: commonly window, a DOM element, or a jQuery object.

Position a Dialog at the Top Right Top ↑

$( "#my_dialog" ).dialog({
    autoOpen: false,
    position: {
        my: "right top",
        at: "right top",
        of: window
    }
});

Demo: Dialog at the top-right corner →

my describes the dialog's alignment point; at describes the target's alignment point. Position strings use horizontal then vertical alignment.

Change Position after Initialization Top ↑

$( "#my_dialog" ).dialog(
    "option",
    "position",
    {
        my: "right top",
        at: "right top",
        of: window
    }
);

Demo: move the Dialog among corners and center →

The same pattern can position the dialog relative to a button or another target by changing of.

Add an Offset Top ↑

Offsets are appended to the my or at coordinates. For example, this places the dialog 20 pixels inward from the target's top-right point:

$( "#my_dialog" ).dialog({
    position: {
        my: "right-20 top+20",
        at: "right top",
        of: window
    }
});

Demo: Dialog position with an offset →

← jQuery UI Dialog tutorial






plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer