*初级小白*~ 2023-02-16 14:22 采纳率: 97.9%
浏览 40
已结题

antdesign表格中div高度如何能撑满整个td

antdesign表格中div高度如何能撑满整个td

img


<template>

  <a-table :dataSource="dataSource" :columns="columns" :scroll="{ x: 2000, y: 300 }" bordered>
    <template #headerCell="{ column }">
      <template v-if="column.dataIndex === 'name'">
        <div class="a">
          <div class="c">姓名</div>
          <div class="b">
            <div>222</div>
            <div>333</div>
          </div>
        </div>
      </template>
    </template>
    <template #bodyCell="{ column, text, record }">
      <template v-if="column.dataIndex === 'name'">
        <div class="b">
            <div class="d">fafsd犯得上地方</div>
            <div class="e">333</div>
          </div>
      </template>
    </template>
  </a-table>
  <div v-for="(item, index) in list" :key="item" draggable @dragstart.stop="onDragStart(item, index)"
    @dragover.stop="onDragOver($event)" @drop.stop="onDrop(index, item)" class="r">{{ item }}</div>
</template>
<script>
import { ref } from 'vue';
export default {
  setup() {
    const dataSource = ref([
      {
        key: '1',
        name: '胡彦斌',
        age: 32,
        address1: '西湖区湖底公园1号西湖区湖底公园1号西湖区湖底公园1号',
        address2: '西湖区湖底公园2号',
        address3: '西湖区湖底公园3号',
        address4: '西湖区湖底公园4号',
        address5: '西湖区湖底公园5号',
        address6: '西湖区湖底公园6号',
        address7: '西湖区湖底公园7号',
      },
      {
        key: '2',
        name: '胡彦祖',
        age: 42,
        address1: '西湖区湖底公园1号',
        address2: '西湖区湖底公园2号',
        address3: '西湖区湖底公园3号',
        address4: '西湖区湖底公园4号',
        address5: '西湖区湖底公园5号',
        address6: '西湖区湖底公园6号',
        address7: '西湖区湖底公园7号',
      },
    ]);
    const columns = ref([
      {
        title: '姓名',
        dataIndex: 'name',
        width: 150,
      },
      {
        title: '年龄',
        dataIndex: 'age',
        width: 150,
      },
      {
        title: 'address1',
        dataIndex: 'address1',
        width: 150,
      }, {
        title: 'address2',
        dataIndex: 'address2',
        width: 150,
      }, {
        title: 'address3',
        dataIndex: 'address3',
        width: 150,
      }, {
        title: 'address4',
        dataIndex: 'address4',
        width: 150,
      }, {
        title: 'address5',
        dataIndex: 'address5',
        width: 150,
      }, {
        title: 'address6',
        dataIndex: 'address6',
        width: 150,
      }, {
        title: 'address7',
        dataIndex: 'address7',
        width: 150,
      }
    ]);
    return {
      dataSource,
      columns,
    };
  },
};
</script>

<style lang="scss" scoped>
.a {
  text-align: center;
  display: flex;
  flex-direction: column;
}

.b {
  display: flex;
  justify-content: space-around;
}

.c {
  border-bottom: 1px solid #eee;
}

.d {
  border-right: 1px solid #eee;
  width: 50%;
  text-align: center;
}

.e {
  width: 50%;
  text-align: center;
}

.r {
  width: 200px;
  height: 50px;
  background-color: aquamarine;
  margin-bottom: 10px;
  line-height: 50px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}

:deep(.ant-table-tbody>.ant-table-row>td) {
  padding: 0px 4px !important;
}

:deep(.ant-table-thead>tr>th) {
  padding: 0px;
}
</style>





  • 写回答

4条回答 默认 最新

  • CSDN专家-showbo 2023-02-16 22:14
    关注

    明白题注意思了,是要d右边border模拟table的边线,需要填满整个td这样才不会出现空白。

    让td relative定位,给d添加after伪元素,absolute定位,高度100%来实现右边border模拟,增加下面2个样式就行

    .d {
      x-border-right: 1px solid #eee;//去掉原来的border改after伪类模拟
      width: 50%;
      text-align: center;
    }
    .ant-table-cell{position:relative}
    .d:after{
      content:'';
      border-right:solid 1px #eee;
      position:absolute;
      right:48%;
      top:0;
      height:100%;margin-right:5px
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 3月2日
  • 已采纳回答 2月22日
  • 创建了问题 2月16日

悬赏问题

  • ¥15 爬取1-112页所有帖子的标题但是12页后要登录后才能 我使用selenium模拟登录 账号密码输入后 会报错 不知道怎么弄了
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点