html - 突出显示垫行单元格的全宽
问题描述
当我想在 Angular 中突出显示一行时遇到问题。HighLight 有效,但不适用于全宽。实际结果:https ://prnt.sc/u4rqjl
我不明白为什么它不是全宽.. Angular 版本:10
我只是看到我这里有问题!:https ://prnt.sc/u4s4tu
html文件:
..
...
<ng-container matColumnDef="reportdate">
<mat-header-cell *matHeaderCellDef mat-sort-header>Date réalisation</mat-header-cell>
<mat-cell *matCellDef="let element"> {{element.reportdate}} </mat-cell>
</ng-container>
<ng-container matColumnDef="action">
<mat-header-cell *matHeaderCellDef mat-sort-header>Action</mat-header-cell>
<mat-cell *matCellDef="let element">
<button *ngIf="element.status == 'KO'" mat-icon-button color="warn">
<mat-icon>build</mat-icon>
</button>
<button *ngIf="element.status == 'OK'" mat-icon-button color="primary">
<mat-icon>verified</mat-icon>
</button>
<button *ngIf="element.status == 'Solved'" mat-icon-button color="accent">
<mat-icon>verified</mat-icon>
</button>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="{'highlight': selectedRowIndex == row.id}" (click)="highlight(row)"></mat-row>
</mat-table>
CSS文件:
.mat-row, .mat-header-row {
min-width: 1123px;
width:100%;
}
.mat-table {
position:relative;
overflow: auto;
max-height: 500px;
width:100%;
height : 100vh;
}
// The table has a scrollbar on the bottom ( because i have a lot of column)
.highlight{
background: #00695c;
}
ts文件:
selectedRowIndex: number = -1;
highlight(row): void {
this.selectedRowIndex = row.id;
}
解决方案
您遇到的问题通常是由最大宽度的过度分配引起的。这意味着您有超过 100% 可能宽度的列!
你可能会使用这个:
.mat-column-$COLUMNNAME {
flex: 0 0 X%;
}
解决方案只是删除它们。在大屏幕上,你的表格看起来不错,在小屏幕上,你的画会有一个滚动条。
推荐阅读
- python - nohup:将标准错误重定向到标准输出错误
- enums - Rust:Enum vs Impl Trait vs?
- reactjs - 如何模拟默认从另一个文件导入的笑话函数
- itext - Itext 不支持 pdf 中的书签
- typescript - 打字稿:将动态数据传递给扩展类
- c++ - 如何在 C++ 中使用 ADO 修复连接执行错误
- scala - 将自定义方法添加到 JsonFormat
- python - 成对求和的运行时间复杂度是多少?
- angular - 使用 nginx 将遗留 URL 重定向/重写到需要哈希的 Angular 应用程序
- python - 如何使用 GROUP BY 和使用 SQLAlchemy 和 Postgresql 获取具有最大更新日期时间的行