简体   繁体   English

如何将jquery对话框的位置更改为中心?

[英]How to change the position of jquery dialog box into center?

I have a jquery dialog box where I am showing the content of a DIV. 我有一个jquery对话框,其中显示了DIV的内容。 But the problem is the dialog box is appearing at the bottom of the page whenever the link button is clicked as the link button also at the bottom of the page but I want this to appear at the top of the page so that user don't have to scroll down to find the dialog box. 但是问题是每当单击链接按钮时,对话框就会出现在页面底部,因为链接按钮也出现在页面底部,但是我希望它显示在页面顶部,以便用户不要必须向下滚动才能找到对话框。

Here is my aspx code: 这是我的aspx代码:

  <a href="#" onclick="OpenDialog('#divNominees','Add Nominee')">

Jquery code: jQuery代码:

   function OpenDialog(obj,title) {
    $(obj).dialog({ title: title, modal: true })
    $(obj).parent().appendTo($("form:first"));
    var p = $(obj).parent();
  }

I would appreciate most if someone help me out of this because I already wasted a whole morning for solving this issue. 如果有人帮助我,我将不胜感激,因为我已经浪费了整个上午来解决这个问题。

Thanks in advance. 提前致谢。

You keep your div not nested with your other tables/divs or whatever. 您不要将div与其他表/ div或其他嵌套在一起。 In the below sample, tblOuter is the id of a table where I wanted the dialog box to be centered. 在下面的示例中,tblOuter是我希望对话框居中的表格的ID。

 $("#divNominees'").dialog({
             modal: true,
             position: { my: "center", at: "center", of: $("#tblOuter") },
             title: "Nominees",
             dialogClass: "ui-dialog-content"
         });
once try with add css 
margin:0 auto; 

or only auto.

阅读文件

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM