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

前端 未结 6 632
梦谈多话
梦谈多话 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:19

    The default dialog is absolutely relative positioned.

    The dialog may expand on giving auto height, but when the page is scrolled , the dialog is reposition itself.

    The only way to do this is, apply these styles to the dialog

    1. Position the dialog in the Window by

      position : ['center',]

    2. Fix the position by using css style

      .fixed-dialog { position:"fixed" }

    3. Add this class to the dialog

      dialogClass : 'fixed-dialog'

    So, the dialog would look like

    $('#dialog-div').dialog({
            position : ['center',10],
            dialogClass: "fixed-dialog"
        });
    

提交回复
热议问题