简体   繁体   中英

@angular/flex-layout 'space-between' layout

I have 2 divs with images in them inside my ng2-flex-layout in my html template. I want 1 of those divs to be on the extreme left and the other on extreme right of the page.

My Code:

 <div class="flex-container" 
     fxLayout="row" 
     fxLayout.md="column"
     fxLayout.sm="column"
     fxLayout.xs="column"
     fxLayoutAlign="space-between center">
  <div class="flex-item" fxLayoutAlign="left" fxFlex=50> <img></img></div>
  <div class="flex-item" fxFlex=50><img></img></div>
</div> 

I am using "@angular/flex-layout": "^2.0.0-beta.4",

I have tried layout-align="space-between center" but no impact.

Can anyone help please?

First: flex-layout requires Angular v2.4.3 or higher, make sure you meet that dependency.

Second: This code renders the result you are asking for. fxLayout="row" and fxLayoutAlign="space-between center" on your flex-container and then tagging your children with flex-item is all you need.

<div class="flex-container" 
    fxLayout="row" 
    fxLayoutAlign="space-between center">
  <div class="flex-item"> 
    <img src="https://codepo8.github.io/canvas-images-and-pixels/img/horse.png" />
  </div>
  <div class="flex-item">
    <img src="https://codepo8.github.io/canvas-images-and-pixels/img/horse.png" />
  </div>
</div>

Result: 结果

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM