【发布时间】:2022-01-26 08:12:57
【问题描述】:
我正在尝试对 mat-table 进行样式化,我想知道 UI 设计师指定的内容是否可行。我想要完成的是这样的:
实际上,我似乎无法让边框框不占用 mat-cell 的整个空间:
我有以下html:
<th class="th" mat-header-cell *matHeaderCellDef mat-sort-header>Passed</th>
<td mat-cell *matCellDef="let attempt" [ngClass]="{'box-green': attempt.passed, 'box-red': !attempt.passed}">
{{ attempt.passed ? 'Passed' : 'Failed' }}
</td>
</ng-container>
使用以下scss:
.box-red {
max-width: 15px;
max-height: 5px;
padding: 2px;
border: 2px solid red ;
background-color: #f8d9dd;
color: red;
border-radius: 10px;
text-align: center;
}
.box-green {
max-width: 20px;
max-height: 10px;
padding: 4px;
border: 2px solid green ;
background-color: #d9f5d9;
color: green;
border-radius: 10px;
text-align: center;
}
这些值是不同的,因为我想强调建议的正常选项(修改高度、宽度、填充、最大宽度、最大高度等)实际上并没有对框的大小产生影响,它总是填满整个单元格。有办法修改吗?
【问题讨论】: