vue-element-admin 列表页面超出滚动改为满屏显示

vue-element-admin 列表页面超出滚动改为满屏显示。

 

效果如下:

列表页面,屏幕自适应始终一屏显示,外层无滚动条,设置表格超出滚动。

 

核心 css

父级元素设置

display: flex;

flex-direction: column;

 

子级元素设置

flex: 1;

 

特别注意 

display: flex; 没有继承性,从最外层的父级元素,一级级的设置到表格的父级元素。

 

表格父级元素 

.screen-card-result {

    display: flex;

    flex-direction: column;

    flex:1 1 auto;

    overflow: hidden;

    margin-bottom: 0;

}

 

表格

<el-table :data="tableData" :fit=true :show-header=true height="100%">

 

知识点总结:

flex:1; 自动撑满父级元素剩余的空间。

flex属性是flex-grow, flex-shrink 和 flex-basis的简写,默认值为0 1 auto。后两个属性可选。
该属性有两个快捷值:auto (1 1 auto) 和 none (0 0 auto)。

flex-shrink属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。
flex-grow属性定义项目的放大比例,默认为0,即如果存在剩余空间,也不放大。


框架样式修改

\src\layout\components\AppMain.vue

<style lang="scss" scoped>

.app-main {

  /* navbar  50  */

  /* 分页高度  72  */

  min-height: calc(100vh - 122px);

  width: 100%;

  display: flex;

  flex-direction: column;

  position: relative;

  overflow: hidden;

}

 

.fixed-header+.app-main {

  padding-top: 50px;

}

 

.hasTagsView {

  .app-main {

    /* 84 = navbar + tags-view = 50 + 34 */

    /* 84 = navbar + tags-view +分页 = 50 + 34 +72 */

    min-height: calc(100vh - 156px);

  }

 

  .fixed-header+.app-main {

    padding-top: 84px;

  }

}

</style>

 

\src\styles\index.scss

.app-container {

  width:100%;

  box-sizing: border-box;

  padding: 10px 10px 0 10px;

  background: #f5f5f5;

  display: flex;

  flex-direction: column;

  flex:1 1 auto;

  overflow: hidden;

  .el-table .cell{

    padding:0;

  }

}

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Irene1991

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

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

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

打赏作者

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

抵扣说明:

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

余额充值