admin管理员组文章数量:1303448
In my Angular app, I’m using mat-table with some long column names. To improve readability, I applied a rotate(-30deg) transformation to the header labels. However, this causes the labels to be overlapped by the next column’s div, instead of appearing on top.
I tried setting the parent z-index to 1 and the span's z-index to 99, but with no success.
How can I ensure that the rotated headers are properly displayed above adjacent columns?
<table
mat-table
[dataSource]="dataSource"
multiTemplateDataRows
class="mat-elevation-z0"
>
<ng-container *ngFor="let column of displayedColumns" [matColumnDef]="column">
<th mat-header-cell *matHeaderCellDef class="header-class">
<span class="rotated-span">
{{ column }}
</span>
</th>
<td mat-cell *matCellDef="let element">
{{ element[column] }}
</td>
</ng-container>
<!-- Header and Row -->
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
</table>
.rotated-span {
position: absolute;
height: 10px;
transform: rotate(-30deg);
transform-origin: center left;
white-space: nowrap;
z-index: 99 !important;
}
.header-class {
height: 100px;
background-color: white;
z-index: 1 !important;
}
本文标签: cssHow to prevent rotated mattable headers from being overlapped by adjacent columnsStack Overflow
版权声明:本文标题:css - How to prevent rotated mat-table headers from being overlapped by adjacent columns? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741759211a2396300.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论