首页 > 其他分享 >element-ui 组件el-table 更改滚动轴样式出现间隙空白

element-ui 组件el-table 更改滚动轴样式出现间隙空白

时间:2023-03-09 17:57:09浏览次数:31  
标签:el style outer element scrollBarWidth ui inner const

空白间隙是由于el-table组件预留的滚动条宽度、高度导致的。

获取滚动条宽度源代码:

import Vue from 'vue';

let scrollBarWidth;

export default function() {
  if (Vue.prototype.$isServer) return 0;
  if (scrollBarWidth !== undefined) return scrollBarWidth;

  const outer = document.createElement('div');
  outer.className = 'el-scrollbar__wrap';
  outer.style.visibility = 'hidden';
  outer.style.width = '100px';
  outer.style.position = 'absolute';
  outer.style.top = '-9999px';
  document.body.appendChild(outer);

  const widthNoScroll = outer.offsetWidth;
  outer.style.overflow = 'scroll';

  const inner = document.createElement('div');
  inner.style.width = '100%';
  outer.appendChild(inner);

  const widthWithScroll = inner.offsetWidth;
  outer.parentNode.removeChild(outer);
  scrollBarWidth = widthNoScroll - widthWithScroll;

  return scrollBarWidth;
};

通过创建一个实际的元素计算出滚动条的宽度。

只要可以在项目中给classel-scrollbar__wrap增加样式

.el-scrollbar__wrap {
  &::-webkit-scrollbar {
    height: 5px;
    width: 5px;
  }
}


标签:el,style,outer,element,scrollBarWidth,ui,inner,const
From: https://www.cnblogs.com/dreamHot/p/17199429.html

相关文章

  • shell 脚本判断指定字符串是否存在
    如我要对my.cnf文件进行参数新增首先判断my.cnf中,是否已经存在要添加的参数,如果没有则添加,有则跳过第一种:#!/bin/shecho"开始修改my.cnf"grep-w"group_concat_......
  • Help document of CAD Plus Mobile
    HelpdocumentforMac中文使用帮助Ifyouhaveanyquestions,pleasesendemailto3167292926@qq.com1.Permissionrequest1.1RequirelocationinformationWhe......
  • 'v-model' directives require the attribute value which is valid as LHS.
    在使用vue时,出现了v-model异常。'v-model'directivesrequiretheattributevaluewhichisvalidasLHS.解决:出现这种问题,一般是v-model的值中做了逻辑判断的处......
  • 基于element-ui进行二次封装的表格组件
    <!--*@description表格组件*@fileNameTableList.vue*@authorQ*@date2021/05/1515:13:45--><template><divclass="table-container"><el-table......
  • CorelDRAW2023即将发布!详解七大新功能
    orelDRAW2023新功能有哪些?CorelDRAW2023最新版本更新怎么样?让我们带您详细了解!CorelDRAWGraphicsSuite2023是矢量制图行业的标杆软件,2023年全新版本为您带来多项新功能和......
  • 第四章.helm3内置函数详解
    一.helm3的内置函数简单介绍1.常用的helm3内置函数(1).quote或squote函数(2).upper和lower函数(3).repeat函数(4).default函数(5).lookup函数2.函数......
  • SQL Server INSERT INTO SELECT语句
    SQLServerINSERTINTOSELECT语句以下内容仅是站长或网友个人学习笔记、总结和研究收藏。不保证正确性,因使用而带来的风险与本站无关! 在本教程中,将学习如何使用S......
  • django中使用celery
    #当你如果只做定时任务,会有一个更为简单的框架-APSchedule:https://blog.csdn.net/qq_41341757/article/details/118759836#使用步骤:-1.把自己写的包,复制......
  • CAD表格怎么转换成Excel表格?CAD表格转EXCEL步骤
    无论是建筑行业还是机械行业,设计师在CAD制图过程中会将项目重要数据以表格的形式插入到图纸中,常见的CAD表格有明细表、工序卡、图样目录等。可是CAD表格在进行数据查找的时......
  • EasyUI的combotree 默认节点选中呢
    $('#selShenqFuwujg').combotree({url:'../../GetFuwujgInfo.aspx?type=GetFuwujgTree&PID=',onLoadSuccess:function(node,data){......