【问题标题】:Angular flex layout: Parent element with fxLayout="column" affects height not width of child elementAngular flex 布局:具有 fxLayout="column" 的父元素影响子元素的高度而不是宽度
【发布时间】:2021-12-27 12:43:47
【问题描述】:

我有一个应用 fxLayout="column" 的父元素。 在父元素内部,我有一个应用 fxFlex="80" 的子元素。

在这种情况下,fxFlex="80" 影响子元素的高度而不是宽度。 将父 flex-layout 更改为 row 时,我得到了预期的结果。

如何使用fxLayout="column" 达到预期结果并仍然使用这种声明式风格?

【问题讨论】:

  • 所以你想要 80% 的宽度?
  • 是但仍在使用弹性布局指令
  • 不确定这是否可行,flexbox“属性”仅在基于 flex-direction 的一维中起作用。

标签: css angular flexbox


【解决方案1】:

以上答案对我有用,对于我的具体情况,我必须将包装元素的高度和宽度设置为 100%

<div class="wrapper" fxLayout="row">
  <div fxLayout="column" fxFlex="80">
    <!-- place other elements here -->
  <div>
</div>

// CSS

.wrapper {
  width: 100%;
  height: 100%;
 }

【讨论】:

    【解决方案2】:

    你能试试这样的吗?

    <div fxLayout="row">
      <div fxLayout="column" fxFlex="80">
        <!-- place other elements here -->
      <div>
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-21
      • 1970-01-01
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      相关资源
      最近更新 更多