jQuery dialog box not in center in Chrome

落爺英雄遲暮 提交于 2020-01-06 18:45:08

问题


in FF and Internet Explorer the dialog box shws up in the center, but in chrome it ends up on the left side.

How can i fix this?

code (self is the object this is in):

     $('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;
        })

回答1:


Perhaps assign a class to the dialog's div e.g:

 $('<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: {

And then create include a css rule that will center the dialogue on the page like so:

.ui-dialogue{margin:0 auto;}

Or somesuch css that will center the dialogue... It's a guess, but might force it to work on most browsers.



来源:https://stackoverflow.com/questions/5639360/jquery-dialog-box-not-in-center-in-chrome

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