【问题标题】:Align horizontally element of table in html page在html页面中水平对齐表格的元素
【发布时间】:2021-03-27 09:43:38
【问题描述】:

我需要我的 angular material 和 css table 才能占据我的 div 的整个宽度,但它不起作用。 同样在我的标题中,我希望图像位于背景中。 这是我工作的 stackblitz 链接:https://stackblitz.com/github/lnquaidorsay/bibliofronthttps://nbwiyjwnw.github.stackblitz.io/product

<div class="container">
    <div fxFlex="60">
        <div class="mat-elevation-z8">
            <table mat-table [dataSource]="dataSource">

                <!-- Position Column -->
                <ng-container matColumnDef="position">
                    <th mat-header-cell *matHeaderCellDef> No. </th>
                    <td mat-cell *matCellDef="let element"> {{element.position}} </td>
                </ng-container>

                <!-- Name Column -->
                <ng-container matColumnDef="name">
                    <th mat-header-cell *matHeaderCellDef> Name </th>
                    <td mat-cell *matCellDef="let element"> {{element.name}} </td>
                </ng-container>

                <!-- Weight Column -->
                <ng-container matColumnDef="weight">
                    <th mat-header-cell *matHeaderCellDef> Weight </th>
                    <td mat-cell *matCellDef="let element"> {{element.weight}} </td>
                </ng-container>

                <!-- Symbol Column -->
                <ng-container matColumnDef="symbol">
                    <th mat-header-cell *matHeaderCellDef> Symbol </th>
                    <td mat-cell *matCellDef="let element"> {{element.symbol}} </td>
                </ng-container>

                <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
                <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
            </table>

            <mat-paginator [pageSizeOptions]="[5, 10, 20]"></mat-paginator>
        </div>

    </div>
</div>

有什么想法吗?

【问题讨论】:

    标签: html css flexbox angular-material


    【解决方案1】:

    products 表似乎已经 100% 宽了。我猜你终于修好了。

    关于标题背景,从mat-toolbar-row元素中删除图像并将此css代码添加到mat-toolbar

    mat-toolbar {
      background-image: url('<path/to/image>');
      background-repeat: no-repeat;
      background-position: center center;
      background-size: cover;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2018-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-01
      • 2013-10-03
      相关资源
      最近更新 更多