首页 > 解决方案 > 如何使用 flex 布局 Angular 使图像的大小响应

问题描述

我想让图像的大小对屏幕的大小做出响应,但它不起作用。我想在小屏幕上显示整个图像,但它只显示图像的一半。如果有人知道是什么问题,请告诉我。谢谢

<div class="flex-container" 
 fxLayout="row" 
 fxLayout.xs="column">
  <div class="flex-item" fxFlex=50>  
      <img alt="image" src="../assets/image.png"/>
  </div>
  <div class="flex-item" fxFlex=33>
     <img  alt="image" src="../assets/image.png"/>
  </div>  
</div>

标签: htmlcssangularangular-materialangular-flex-layout

解决方案


我这样做如下:

 <div fxFlexFill class="example-container">
    <div fxLayout="column" fxLayoutGap="32px" [style.height]="'100%'">
      <mat-card class="card-margins">
        <mat-card-title></mat-card-title>
          <div
            fxLayout="row"
            fxLayoutGap="32px"
            fxLayout.lt-sm="column"      
            fxLayoutGap.lt-sm="10px">
            <div fxFlex="0 100 100%">
                <img mat-card-image src="../assets/image.png" alt="Free image">
            </div>
          </div>
          <div fxFlex="0 0 calc(50%-36px)">
            <mat-card-content>
              <p>Hi, how are you?</p>
            </mat-card-content>
            </div>
        </mat-card>
      </div>
    </div>

推荐阅读