简体   繁体   English

我无法以角度对齐材料设计卡

[英]i can't align material design cards in angular

i have used ng-flex so they are responsive.我使用了 ng-flex,所以它们反应灵敏。 but I want to align them so that they are all the same height.但我想对齐它们,使它们的高度相同。 how you can see they aren't alinged .你怎么能看到他们没有变态

 .content { padding: 16px; } .content > mat-card { width: 200px; }
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class="content"> <div fxLayout="row wrap" fxLayoutGap="16px grid"> <div fxFlex="25%" fxFlex.xs="100%" fxFlex.sm="33%" *ngFor="let manga of mangaList"> <mat-card class="mat-elevation-z4" > <mat-card-header> <mat-card-title>{{ manga.title }}</mat-card-title> </mat-card-header> <img mat-card-image src="{{ manga.preview }}"> <mat-card-actions> <button mat-button>Leggi</button> <button mat-button (click)="updateBookmark(manga)"> <i *ngIf="manga.bookmarked == 'false'; else ifBookmarked" class="fa fa-bookmark-o fa-lg"></i> <ng-template #ifBookmarked> <i class="fa fa-bookmark fa-lg"></i> </ng-template> </button> </mat-card-actions> </mat-card> </div> </div> </div>

Give the card class itself a limit with maxheight + height .给卡片类本身一个 maxheight + height 的限制。 So all cards same height.所以所有的卡片高度相同。 If you want the contents of the card to have all same height you have to hardcode the height for mat-card-header, the image and mat-card-actions.如果您希望卡片的内容具有相同的高度,您必须硬编码 mat-card-header、图像和 mat-card-actions 的高度。 To regulate the image height container make a div arround it.要调节图像高度容器,请在它周围放置一个 div。 Something like that:类似的东西:

 <div fxLayout="row grid"> <mat-card *ngFor="let manga of mangaList"> <mat-card-header> -- Content -- </mat-card-header> <div> <img> </div> <mat-card-actions> -- Content -- </mat-card-actions> </mat-card> </div>

 Card { height: 200px; max-height 200px; mat-card-header { height 20px; max-height 20px; } image-div { height 60px; max-height 60px; } mat-card-actions { height 20px; max-height 20px; } }

Also i see on the 3rd one is the Title to long.另外我在第三个看到的标题是长。 If you wanna keep the Title length you gotta adjust height如果你想保持标题长度,你必须调整高度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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