Position jquery UI dialog

前端 未结 3 1974
没有蜡笔的小新
没有蜡笔的小新 2021-02-19 21:02

How can I position the jquery UI dialog SPECIFICALLY, so that it goes to a position not defined by center, top, etc.

Thanks, I have tried to be as specific as posible.

3条回答
  •  余生分开走
    2021-02-19 21:35

    If you want to use absolute positioning, the dialog's position option is what you need. If you need to position relative to other elements, there's another easy technique you use, jquery UI's $('selector').position(options); (seen at: http://jqueryui.com/demos/position/)

    For example:

    // div to position against
    var $div = $('#someDiv');
    
    // Open dialog (positioning won't work on hidden elements)
    $dialog.dialog('open');
    
    // position newly opened dialog (using its parent container) below $div.
    $dialog.dialog('widget').position({
      my: "left top",
      at: "left bottom",
      of: $div
    });
    

提交回复
热议问题