Can I center a jQuery UI dialog to a div?

∥☆過路亽.° 提交于 2019-12-05 18:21:03

You're correct, .position() is the way to go here, like this:

​$("#dialog").dialog()
            .parent() //remember .dialog() wraps the content in another <div>
            .position({ my: 'center', at: 'center', of: '#parent' });
  //or just .position({ of: '#parent' });

​ In the above #parent it the parent element selector, you can give it a try here. You want the my and at properties to be center so they're centered op top of one another, then the of selector is the parent selector you want it centered in.

I specified all relevant options for illustration, but since center is the default for my and at, you can specify just the of like I have in the commented line above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!