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

需求

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

最初效果

在这里插入图片描述

优化后效果

在这里插入图片描述

<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>
<script>
export default {
  props: {
    visible: {
      type: Boolean
    }
  },
  data() {
    return {
    }
  },
  methods: {
    // 确认
    onSubmit() {
      const data = {}
      this.$emit('submit', data)
    },
    // 关闭弹窗
    handleClose() {
      this.$emit('close')
    }
  }
}
</script>
<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>
  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xuelong-ming

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值