Vue3框架中让table合计居中对齐

第一步:给它加一个类名 center-table 如下:

html 复制代码
 <el-table
      :data="datas.shows"
      max-height="600px"
      show-summary
      stripe
      border
      style="width: 100%"
      :header-cell-style="{ textAlign: 'center' }"
      :cell-style="{ textAlign: 'center' }"
      class="center-table"
    ></el-table>

第二步: 使用v-deep选择器

css 复制代码
:deep(.center-table td), 
:deep(.center-table th) {
  text-align: center !important;
}

效果

原创作者:吴小糖

创作时间:2023.11.24

相关推荐
whinc6 小时前
JavaScript技术周刊 2026年第18周
javascript
码海扬帆:前端探索之旅6 小时前
深度定制 uni-combox:新增功能详解与实战指南
前端·vue.js·uni-app
谷雨不太卷6 小时前
进程的状态码
java·前端·算法
打小就很皮...7 小时前
基于 Python + LangChain + RAG 的知识检索系统实战
前端·langchain·embedding·rag
whinc7 小时前
JavaScript技术周刊 2026年第17周
javascript
BJ-Giser7 小时前
Cesium 烟雾粒子特效
前端·可视化·cesium
空中海7 小时前
02 ArkTS 语言与工程规范
java·前端·spring