【问题标题】:How to change the position of jquery dialog box into center?如何将jquery对话框的位置更改为中心?
【发布时间】:2013-08-16 06:46:33
【问题描述】:

我有一个 jquery 对话框,我在其中显示 DIV 的内容。但问题是,每当单击链接按钮时,对话框就会出现在页面底部,因为链接按钮也在页面底部,但我希望它出现在页面顶部,这样用户就不会必须向下滚动才能找到对话框。

这是我的 aspx 代码:

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

jQuery 代码:

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

如果有人帮助我解决这个问题,我将不胜感激,因为我已经浪费了整个上午来解决这个问题。

提前致谢。

【问题讨论】:

    标签: c# javascript jquery asp.net


    【解决方案1】:

    您的 div 不会与其他表/div 或其他任何东西嵌套。在下面的示例中,tblOuter 是我希望对话框居中的表格的 ID。

     $("#divNominees'").dialog({
                 modal: true,
                 position: { my: "center", at: "center", of: $("#tblOuter") },
                 title: "Nominees",
                 dialogClass: "ui-dialog-content"
             });
    

    【讨论】:

      【解决方案2】:
      once try with add css 
      margin:0 auto; 
      
      or only auto.
      

      【讨论】:

        【解决方案3】:

        阅读Documentation

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-11-13
          • 2013-01-05
          • 1970-01-01
          • 2011-04-30
          • 1970-01-01
          • 2012-09-15
          • 2011-03-24
          • 1970-01-01
          相关资源
          最近更新 更多