Element Plus Container布局容器设置height: 100%无效

Element Plus Container布局容器设置height: 100%无效


一、在el-container中设置高度无效


  1. 设置高度,el-container高度等于父元素#app的高度,#app的高度的父节点是body,body的父节点是html,默认情况下html和body的高度为auto,浏览器不会自动给标签添加高度,因此自然就无效了

二、解决

  1. 在App.vue中添加
html,body,#app{
  height: 100%
}

然后在el-container中添加height

转 载 : \color{#FF00FF}{转载:}
https://blog.csdn.net/zengzenghaha/article/details/83018605


  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
为了实现vue3+ element plus+ts的门户网站自适应布局,可以按照以下步骤进行操作: 1. 安装vue-cli并创建项目 ```shell npm install -g @vue/cli vue create vue3-elementplus-mock-echarts ``` 2. 安装element-plus和sass ```shell npm install element-plus sass sass-loader ``` 3. 在main.ts中引入element-plus和sass ```typescript import { createApp } from 'vue' import App from './App.vue' import router from './router' import store from './store' import ElementPlus from 'element-plus' import 'element-plus/lib/theme-chalk/index.css' import './assets/scss/index.scss' createApp(App).use(store).use(router).use(ElementPlus).mount('#app') ``` 4. 在App.vue中使用element-plus的Layout组件进行布局 ```vue <template> <div class="app-container"> <el-container> <el-header>Header</el-header> <el-container> <el-aside>Aside</el-aside> <el-main>Main</el-main> </el-container> <el-footer>Footer</el-footer> </el-container> </div> </template> <script lang="ts"> import { defineComponent } from 'vue' export default defineComponent({ name: 'App', }) </script> <style lang="scss" scoped> .app-container { height: 100%; display: flex; flex-direction: column; .el-container { flex: 1; height: 100%; .el-header { height: 60px; } .el-aside { width: 200px; } .el-main { flex: 1; } .el-footer { height: 60px; } } } </style> ``` 5. 在index.html中设置meta标签实现自适应布局 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" /> <title>vue3-elementplus-mock-echarts</title> </head> <body> <div id="app"></div> </body> </html> ```
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值