html - Angular 5 Material将跨度居中到垫头单元格中

标签 html css angular angular5

在我的 angular5 应用程序中,我使用 Material 表来显示一些数据。

进入 mat-h​​eader-cell 我有一个 span 和一个 img 并试图正确对齐它们。

这是现在的样子:

enter image description here

这里是一段html代码:

<ng-container matColumnDef="batchState">
<mat-header-cell *matHeaderCellDef style="border: 1px solid white;"> 
    <span style="border: 1px solid white;">Batch state </span>
    <img style="border: 1px solid white;" src='../../assets/filter_list.png' (click)="filterByState()" 
        matTooltip="Filter by state" />
</mat-header-cell>
<mat-cell *matCellDef="let inst">
        {{inst.batchState}} 
</mat-cell>
</ng-container>

我想让我的 span 显示在单元格的左中 Angular ,试过 text-align:center; left:0px;padding-top: 25%; padding-bottom: 25% (在我的 span 元素内)但是那些 css 不起作用,有什么办法可以实现吗?

最佳答案

解决方案发现将 css 添加到 mat-h​​eader-cell -> display: flex;对齐元素:居中;

<ng-container matColumnDef="batchState">
<mat-header-cell *matHeaderCellDef style="border: 1px solid white;display: flex; align-items: center;"> 
    <span style="border: 1px solid white;">Batch state </span>
    <img style="border: 1px solid white;" src='../../assets/filter_list.png' (click)="filterByState()" 
        matTooltip="Filter by state" />
</mat-header-cell>
<mat-cell *matCellDef="let inst">
        {{inst.batchState}} 
</mat-cell>
</ng-container>

enter image description here

关于html - Angular 5 Material将跨度居中到垫头单元格中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52623069/

相关文章:

html - 如何将网格项的子元素重叠到下一列?

html - 如何在html中显示本地时间?

html - 如何允许 Bootstrap 下拉项列表显示在类 ="well"之外

Angular Material 嵌套拖放

css - Angular Material 2 主题 - 输出单个文件或延迟加载

html - 在 <div> 元素内居中

通过 Google Analytics 跟踪出站链接的 HTML 有效方法?

html - 仅使用 CSS 切换单选输入

javascript - 单击时恢复 CSS 过渡

Angular2延迟更新 View