jQuery - Dialog auto-resize on dynamic content and maintain center position

前端 未结 6 636
梦谈多话
梦谈多话 2020-12-30 13:51

I have a jQuery Dialog box and Am loading the content using Ajax.

The Dialog is initially in the center of the page. The problem , here is , Since its a dynamic con

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 14:16

    I use that function:

    function centerDialog(id){
    
      var d = $('#'+id).closest('.ui-dialog'),
          w = $(window);
    
      d.css({
    
        'top':(w.height()-d.outerHeight())/2,
        'left':(w.width()-d.outerWidth())/2
    
      });
    
    }
    

提交回复
热议问题