angular - Flex 布局高度问题

标签 angular css flexbox angular-flex-layout

我在应用 fxFlex 时遇到增加和减少 div 高度的问题。我为容器提供了动态高度。我该如何解决这个问题?

提前致谢。 Demo here

<div class="container">
   <div fxFlex="30"> Some Text </div>
   <div fxFlex="40"> Some Text </div>
   <div fxFlex="30"> Some Text </div>
</div>

注意:动态提供容器的高度(根据窗口大小/调整大小)

截图: enter image description here

最佳答案

使用 fxFlexFill 可以执行以下操作:StackBlitz HERE

<div class="container" style="padding: 20px" fxFlexFill fxLayoutGap="10px">
  <div fxFlex="30"><mat-card>Some Text</mat-card></div>
  <div fxFlex="40"><mat-card>Some Text</mat-card></div>
  <div fxFlex="30"><mat-card>Some Text</mat-card></div>
</div>

fxFlexFill 允许您根据它可以容纳的内容设置 div 的高度。

所以我为您的 HTML 页面添加了以下 CSS 以根据您的屏幕采用最大高度。

html, body {height: 100%; margin: 0;}

演示:

enter image description here

关于angular - Flex 布局高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55567144/

相关文章:

html - 为什么这些 flex 元素没有包裹起来?

html - 将 vh 与 flexbox 一起使用时如何修复 Component-Streching?

javascript - 访问回调中的类属性

angular - @HostBinding 在 Angular 中带有变量类

javascript - Highcharts:如何消除堆叠条形/列之间的微小空间

javascript - 是否可以在查看 html 源代码时隐藏包含部分

html - 3 列(框)布局

Angular - 延迟加载谷歌地图 - "You have included the Google Maps JavaScript API multiple..."

angular - 使用 Github 操作找不到 Azure 静态 Web 应用程序 : staticwebapp. config.json

html - Github GH Pages 更改 h1 的字体