jQuery UI dialog box not positioned center screen

后端 未结 23 3137
失恋的感觉
失恋的感觉 2020-12-01 00:31

I have a jQuery dialog box that is meant to position in the middle of the screen. However, it seems slightly off-center vertically.

Here is the code:

         


        
23条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-01 01:27

    If your viewport gets scrolled after the dialog displays, it will no longer be centered. It's possible to unintentionally cause the viewport to scroll by adding/removing content from the page. You can recenter the dialog window during scroll/resize events by calling:

    $('my-selector').dialog('option', 'position', 'center');
    

提交回复
热议问题