当前位置:   article > 正文

Element UI 之table表格样式_el-table好看的

el-table好看的

需求:
在这里插入图片描述
鼠标移入:
在这里插入图片描述
实现:

<template>
  <el-table
    :data="tableData"
    style="width: 800px"
    height="440px"
    :header-cell-style="{
      background: '#1C2E45',
      height: '40px',
      padding: '0',
      color: '#a0b2d3',
    }"
    :cell-style="cellStyle"
    class="table-list"
  >
    <el-table-column
      label="序号"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
      <template scope="scope">
        {{ scope.$index + 1 }}
      </template>
    </el-table-column>
    <el-table-column
      prop="time"
      label="日期"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
    <el-table-column
      prop="title"
      label="标题"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
    <el-table-column
      prop="briefIntroduction"
      label="简介"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
    <el-table-column
      prop="author"
      label="作者"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
    <el-table-column
      prop="star"
      label="星级"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
    <el-table-column
      prop="reading"
      label="阅读量"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
    <el-table-column
      prop="address"
      label="地址"
      align="center"
      header-align="center"
      :show-overflow-tooltip="true"
      width="100"
    >
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        {
          id: 1,
          time: "2012-02-10 02:25:28",
          title: "实没风越花九",
          briefIntroduction: "论问严复周较选小提。",
          author: "朱娜",
          star: "★★★",
          reading: 2044,
          address: "湖南省 衡阳市 衡南县",
        },
        {
          id: 2,
          time: "1991-02-15 21:36:16",
          title: "员通了",
          briefIntroduction: "说六原红论提个。",
          author: "蒋杰",
          star: "★★★★★",
          reading: 950,
          address: "海南省 三亚市 -",
        },
        {
          id: 3,
          time: "1998-08-20 11:15:58",
          title: "器来此只小",
          briefIntroduction: "么立院部油起确带属然状装。",
          author: "杨敏",
          star: "★★★★",
          reading: 827,
          address: "江西省 萍乡市 安源区",
        },
        {
          id: 4,
          time: "2016-08-04 08:39:45",
          title: "听期务半",
          briefIntroduction: "名直维发现。",
          author: "杨芳",
          star: "★★",
          reading: 2640,
          address: "福建省 龙岩市 其它区",
        },
        {
          id: 5,
          time: "1990-10-21 19:32:04",
          title: "北由给实",
          briefIntroduction: "真产经门克无百外。",
          author: "程军",
          star: "★★★",
          reading: 1290,
          address: "黑龙江省 齐齐哈尔市 富裕县",
        },
        {
          id: 6,
          time: "2001-07-26 15:50:19",
          title: "热革形",
          briefIntroduction: "转人新加农数位那调这高。",
          author: "康明",
          star: "★",
          reading: 3885,
          address: "辽宁省 铁岭市 昌图县",
        },
        {
          id: 7,
          time: "1989-10-30 11:48:07",
          title: "容发号政及带",
          briefIntroduction: "名见西平东月。",
          author: "石秀英",
          star: "★★",
          reading: 2637,
          address: "湖北省 孝感市 安陆市",
        },
        {
          id: 8,
          time: "2002-05-12 10:03:35",
          title: "接开统按斯的南",
          briefIntroduction: "压解能放质斯设。",
          author: "郭刚",
          star: "★★",
          reading: 3224,
          address: "福建省 龙岩市 新罗区",
        },
        {
          id: 9,
          time: "2003-04-24 18:29:43",
          title: "共因证会",
          briefIntroduction: "强须计克内斯那得深适起位并主适。",
          author: "尹伟",
          star: "★★",
          reading: 4824,
          address: "青海省 玉树藏族自治州 称多县",
        },
        {
          id: 10,
          time: "2004-07-25 16:34:24",
          title: "来许路示",
          briefIntroduction: "参观次儿实和天第头酸都还济。",
          author: "黎敏",
          star: "★★★",
          reading: 3097,
          address: "辽宁省 铁岭市 其它区",
        },
        {
          id: 11,
          time: "1996-06-08 23:53:39",
          title: "工水元器",
          briefIntroduction: "非六起商地战算。",
          author: "傅杰",
          star: "★★★",
          reading: 2868,
          address: "山东省 莱芜市 其它区",
        },
        {
          id: 12,
          time: "2013-03-28 02:05:10",
          title: "状海别组织能",
          briefIntroduction: "后但三选群界界种同称机压调。",
          author: "雷敏",
          star: "★★★",
          reading: 3717,
          address: "浙江省 衢州市 龙游县",
        },
        {
          id: 13,
          time: "1986-11-18 11:25:24",
          title: "义海件上观",
          briefIntroduction: "象从组员东外转律素。",
          author: "林军",
          star: "★",
          reading: 2383,
          address: "湖南省 郴州市 苏仙区",
        },
        {
          id: 14,
          time: "1991-02-08 04:22:59",
          title: "达劳那精多",
          briefIntroduction: "到包族太商记路看龙队而。",
          author: "姜平",
          star: "★★",
          reading: 2627,
          address: "江西省 抚州市 资溪县",
        },
        {
          id: 15,
          time: "2021-01-05 23:07:45",
          title: "使情率近资管",
          briefIntroduction: "于满角命设元声感带思。",
          author: "赖超",
          star: "★★★★★",
          reading: 368,
          address: "澳门特别行政区 离岛 -",
        },
        {
          id: 16,
          time: "2014-02-28 09:55:56",
          title: "管传月转保",
          briefIntroduction: "做果求住流完代口样开达人类叫。",
          author: "罗娜",
          star: "★★★★",
          reading: 860,
          address: "香港特别行政区 新界 大埔区",
        },
        {
          id: 17,
          time: "2014-04-22 21:30:24",
          title: "离完展毛队党形",
          briefIntroduction: "照农者不数口。",
          author: "卢霞",
          star: "★★",
          reading: 3326,
          address: "内蒙古自治区 赤峰市 翁牛特旗",
        },
        {
          id: 18,
          time: "1995-10-26 12:56:25",
          title: "么地才律精斯",
          briefIntroduction: "为前起反表有历立者以因多道场技。",
          author: "邱明",
          star: "★★★★",
          reading: 1595,
          address: "广西壮族自治区 防城港市 防城区",
        },
        {
          id: 19,
          time: "1983-01-04 21:16:20",
          title: "半了受两",
          briefIntroduction: "片期但先认就资流上他去道界。",
          author: "胡军",
          star: "★★★★",
          reading: 2379,
          address: "吉林省 四平市 双辽市",
        },
        {
          id: 20,
          time: "2013-06-26 22:52:17",
          title: "素记而将而",
          briefIntroduction: "来高起存等。",
          author: "周霞",
          star: "★★★★",
          reading: 1662,
          address: "江苏省 盐城市 盐都区",
        },
      ],
    };
  },
  methods: {
    // 表格隔行换色
    cellStyle(row, column, rowIndex, columnIndex) {
      if (row.rowIndex % 2 == 0) {
        return "background: #12243C;"; //双数行
      } else {
        return " background: #1C2E45;"; //单数行
      }
    },
  },
};
</script>
<style lang="scss">
.table-list {
  &.el-table {
    font-size: 20px;
    width: 100%;
    height: 100%;
    background: #192a3f !important;

    &::before {
      height: 0;
    }
    .is-leaf {
      border: none;
    }
    thead {
      border-bottom: 2px solid rgba(255, 255, 255, 1);
    }
    th {
      background: transparent;
      border-bottom: none;
      .cell {
        font-weight: bold;
        color: #a0b2d3;
      }
    }
    tr {
      height: 40px; //
      &.el-table__row:hover {
        td {
          background: #ebeef5 !important; //划过 背景颜色
        }
      }
    }
    td {
      background: transparent;
      border-bottom: none;
      padding: 0;
      .cell {
        overflow: hidden;
        font-weight: bold;
        color: #a0b2d3;
      }
    }

    // 滚动条宽高
    .el-table__body-wrapper::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }
    // 滚动条的滑块
    .el-table__body-wrapper::-webkit-scrollbar-thumb {
      background-color: rgb(75, 137, 212);
      border-radius: 5px;
    }
    // 滚动条背景颜色
    .el-table__body-wrapper::-webkit-scrollbar-track-piece {
      background-color: #1c2e45;
    }
  }
}

.el-tooltip__popper.is-dark {
  // table 提示框样式
  min-width: fit-content !important;
  background: #192a3f !important;
  color: #a0b2d3 !important;
  font-size: 20px;
}
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • 260
  • 261
  • 262
  • 263
  • 264
  • 265
  • 266
  • 267
  • 268
  • 269
  • 270
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 296
  • 297
  • 298
  • 299
  • 300
  • 301
  • 302
  • 303
  • 304
  • 305
  • 306
  • 307
  • 308
  • 309
  • 310
  • 311
  • 312
  • 313
  • 314
  • 315
  • 316
  • 317
  • 318
  • 319
  • 320
  • 321
  • 322
  • 323
  • 324
  • 325
  • 326
  • 327
  • 328
  • 329
  • 330
  • 331
  • 332
  • 333
  • 334
  • 335
  • 336
  • 337
  • 338
  • 339
  • 340
  • 341
  • 342
  • 343
  • 344
  • 345
  • 346
  • 347
  • 348
  • 349
  • 350
  • 351
  • 352
  • 353
  • 354
  • 355
  • 356
  • 357
  • 358
  • 359
  • 360
  • 361
  • 362
  • 363
  • 364
  • 365
  • 366
  • 367
  • 368
  • 369
  • 370
  • 371
  • 372
  • 373
  • 374
  • 375
  • 376
  • 377
  • 378
  • 379
  • 380
  • 381
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号