【问题标题】:How to align mat-cell content with icon to right on angular2/material?如何在 angular2/material 上将 mat-cell 内容与图标对齐?
【发布时间】:2018-02-27 03:28:18
【问题描述】:

开始我的代码:

<!-- Edit Column -->
<ng-container mdColumnDef="edit">
  <md-header-cell *mdHeaderCellDef> {{'companies.edit-column' | translate}}</md-header-cell>
  <md-cell *mdCellDef="let element"><a (click)="toCompany(element.id)"><md-icon class="md-dark">edit</md-icon></a></md-cell>
</ng-container>

要求是将编辑图标的位置调整到右侧(相对于材料设计的右侧填充)?现在它似乎被强行左停靠。将style="{text-align: right}" 应用于 md-cell 不起作用。

库版本

"@angular/material": "2.0.0-beta.10"
"@angular/cdk": "^2.0.0-beta.10",
"@angular/common": "^4.1.3"

【问题讨论】:

  • 你是否也在使用 FlexLayout?你可以在这里使用 fxLayout 指令,用 fxFlex 定位应该不是问题

标签: html css angular angular-material angular-material2


【解决方案1】:

使用以下任何一种:

mat-cell{
  display:flex !important;
  justify-content:flex-end!important;

}

::ng-deep .mat-cell{
  display:flex !important;
  justify-content:flex-end!important;
}

DEMO

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-02-18
  • 2018-12-28
  • 2020-11-16
  • 2020-05-31
  • 2021-05-16
  • 1970-01-01
  • 2014-12-24
  • 1970-01-01
相关资源
最近更新 更多