dialog The dialog box is vertically centered

ps: style cannot be written in scoped, otherwise it will fail

1. Give the dialog a class name, custom-class="dialogStyle"

<el-dialog
      v-model="dialogVisible"
      :title="dialogTitle"
      width="38%"
      center
      destroy-on-close
      V-el-drag-dialog
      V-if="dialogVisible"
      append-to-body
      custom-class="dialogStyle"
      :before-close="handleClose"
    >
      <!-- formID 指的是ID -->
      <indexForm
        :newFormdata="newFormdata"
        ref="fromViewRef"
      />
    </el-dialog>

2. Copy and paste this code directly to take effect.

<style>
.dialogStyle {
  display: flex;
  flex-direction: column;
  margin: 0 !important;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100% - 30px);
  max-width: calc(100% - 30px);
}
</style>

If there is too much dialog content to scroll, you need to add the following sentence

::v-deep .el-dialog .el-dialog__body{
  flex:1; 
  overflow: auto; 
}

Guess you like

Origin blog.csdn.net/CMDN123456/article/details/131590531