elementUI 弹窗居中 并且tabs组件 tab-position=“left“时显示的样式优化

需求

项目需要自定义字段,但是有个样式不太好实现,记录一下。

最初效果

优化后效果

html 复制代码
<template>
  <el-dialog title="新建字段" :visible.sync="visible" width="50%" :before-close="handleClose">
    <div class="tabs-box">
      <div class="tabs-title">
        <span class="tabs-title-type">选择字段类型</span>
        <span class="tabs-title-stats">字段属性</span>
      </div>
      <el-tabs :tab-position="'left'" type="card" style="height: calc(100% - 50px);">
        <el-tab-pane label="单行文本"></el-tab-pane>
        <el-tab-pane label="多行文本">多行文本</el-tab-pane>
        <el-tab-pane label="下拉列表">下拉列表</el-tab-pane>
        <el-tab-pane label="单选">单选</el-tab-pane>
        <el-tab-pane label="多选">多选</el-tab-pane>
        <el-tab-pane label="日期">日期</el-tab-pane>
        <el-tab-pane label="数字">数字</el-tab-pane>
        <el-tab-pane label="附件">附件</el-tab-pane>
      </el-tabs>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="onSubmit">确 定</el-button>
    </span>
  </el-dialog>
</template>
js 复制代码
<script>
export default {
  props: {
    visible: {
      type: Boolean
    }
  },
  data() {
    return {
    }
  },
  methods: {
    // 确认
    onSubmit() {
      const data = {}
      this.$emit('submit', data)
    },
    // 关闭弹窗
    handleClose() {
      this.$emit('close')
    }
  }
}
</script>
css 复制代码
<style lang="scss" scoped>
.tabs-box {
  height: 100%;
  box-sizing: border-box;

  .tabs-title {
    width: 100%;
    height: 50px;
    line-height: 50px;
    font-size: 14px;
    font-weight: 900;
    color: #000;

    .tabs-title-type {
      display: inline-block;
      width: 130px;
    }

    .tabs-title-stats {
      display: inline-block;
      margin-left: 20px;
	  /* 设置竖线 */
      &::before {
        content: "";
        position: absolute;
        display: inline-block;
        background: #e4e7ed;
        height: 450px; /* 设置竖线高度 */
        width: 1px;
        left: 150px;
        top: 54px;
      }
    }
  }
}
</style>

<style scoped lang="scss">
::v-deep {
  .el-dialog {
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-height: 500px;
    max-height: calc(100% - 30px);
    max-width: calc(100% - 30px);

    .el-dialog__body {
      flex: 1;
      overflow: auto;
      padding-top: 0;
      height: 100%;
      box-sizing: border-box;
    }
  }

  .el-tabs__item {
    text-align: center !important;
    width: 130px;
    text-overflow: ellipsis;
    /* 溢出显示省略号 */
    overflow: hidden;
    /* 溢出隐藏 */
    white-space: nowrap;
    /* 强制不换行 */
  }
}
</style>
相关推荐
_风满楼几秒前
TDD实战-会议室冲突检测的红绿重构循环
前端·javascript·算法
Rkgua5 分钟前
JS中的惰性函数基本介绍
前端·javascript
客场消音器22 分钟前
我用两周半 Vibe Coding 做了一个前额叶训练的微信小程序
前端·javascript·后端
铁皮饭盒1 小时前
成为AI全栈 - 第4课:Drizzle ORM SQLite Elysia 数据库实战
前端·后端
ascarl20101 小时前
Linux.do 帖子整理:AI 调用 Chrome DevTools 调试前端页面
linux·前端·人工智能
DanCheOo2 小时前
开源 | 我是怎么用 ai-memory 让 Cursor 每次开新对话都自动知道项目背景的
前端·人工智能·ai·ai编程
azhou的代码园2 小时前
基于SpringBoot+Vue的家教小程序
vue.js·spring boot·小程序·毕业设计·家教小程序
MPGWJPMTJT2 小时前
告别手动切换 Node 版本:从 nvm 迁移到 Volta
前端
Apifox2 小时前
Apifox 近期更新|AI Agent Debugger、A2A Debugger、Postman API 导入、Ask AI 侧边栏对话
前端·人工智能·后端
嗷o嗷o2 小时前
Android 前台服务为什么越来越难用了?很多问题不是限制多,而是你任务模型就不该用 FGS
前端