2011-04-12 238 views
0

中的jQuery对话框不在中间,对话框在中心位置缩小,但在Chrome中位于左侧。在FF和Internet Explorer中,Chrome浏览器中的Chrome浏览器

我该如何解决这个问题?

代码(self是,这是在对象):

 $('form').live('submit',function(e){ 
      e.preventDefault(); 
      var $this = this; 
      console.log('click submit') 
      $('<div>', 
        {html: 'Are you sure you want to submit this table?<br/> All undo information will be lost.'}) 
      .dialog({ 
       modal: true, 
       title: 'Are You Sure?', 
       buttons: { 
        ok: function(){ 
         $.get($this.action,$($this).serialize()+'&page='+self.pageOn,function(data){ 
          console.log(data); 
          self.pageChanged = false; 
          self.origPage = $('#page').clone(); 
          self.lastClick = $('#page').clone(); 
         }) 
         $(this).dialog('close'); 
        }, 
        cancel: function(){ 
         $(this).dialog('close'); 
        } 
       }, 
       beforeClose: function(){ 
        $(this).remove(); 
       } 
      }) 

      return false; 
     }) 

回答

0

也许指定一个类为对话框的DIV如:

$('<div class="ui-dialogue">', 
       {html: 'Are you sure you want to submit this table?<br/> All undo information will be lost.'}) 
     .dialog({ 
      modal: true, 
      title: 'Are You Sure?', 
      buttons: { 

,然后创建包含CSS规则,将居中在页面上的对话像这样:

.ui-dialogue{margin:0 auto;} 

或某些css,将中心对话... 这是一个猜测,但可能会强制它在大多数浏览器上工作。

+0

thnx^_ ^似乎工作时,我将它应用到窗口小部件元素 – Neal 2011-04-12 18:33:49

+0

在我的情况下,对话框水平居中,但出现在顶部。 我添加了'position:'center''选项,但不起作用。有任何想法吗? – zur4ik 2014-04-27 01:13:49

相关问题