Search code examples
angulartypescriptmaterial-designangular-flex-layout

How to increase height of one component using FlexLayout, Angular 4, Material Design


I want to get a gap between the two rows, such as shown in plunkr but I also want to have the middle cell in blue, on the top row, be a different height.

When I change the height of one cell it changes the entire row. The one I was larger is class="two"

I have this html:

<md-card class="card-demo">
  <md-card-title>another example</md-card-title>
  <md-card-subtitle>some test work.
  </md-card-subtitle>
  <md-card-content>
    <div fxLayout="column" ng-app="demoApp" layout-fill>
      <div fxLayout="row" fxLayoutGap="20px" flex>
        <div class="one" fxFlex="70"> test1 </div>
        <div class="two" fxFlex="25"> test2 </div>
        <div class="three" fxFlex="25"> test2 </div>
      </div>
      <div fxLayout="column" fxLayoutGap flex>
        <div class="four" fxFlex="150"> test1
          <p>one</p>
          <p>one</p>
        </div>
      </div>
    </div>
  </md-card-content>
</md-card>

And this css:

.one {
    background-color: red;
}

.two {
    background-color: blue;
}

.three {
    background-color: green;
}
.four {
    background-color: yellow;
}

Solution

  • You can add fxLayoutAlign to change default flex behaviour

      <div fxLayout="row" fxLayoutGap="20px" flex fxLayoutAlign="stretch flex-start">
        <div class="one" fxFlex="70"> test1 </div>
        <div class="two" fxFlex="25"> test2 </div>
        <div class="three" fxFlex="25"> test2 </div>
      </div>
    

    https://stackblitz.com/edit/angular-pmborb?embed=1&file=app/app.module.ts