Skip to content

Commit 3b70d20

Browse files
crisbetojelbourn
authored andcommitted
fix(table): extra elements throwing off table alignment (#12645)
Fixes extra decorative elements like badges or ripples throwing off the alignment in tables. Fixes #11165.
1 parent 70d1be8 commit 3b70d20

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib/table/table.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ mat-row, mat-header-row, mat-footer-row {
3737
}
3838
}
3939

40-
mat-cell:first-child, mat-header-cell:first-child, mat-footer-cell:first-child {
40+
// Note: we use `first-of-type`/`last-of-type` here in order to prevent extra
41+
// elements like ripples or badges from throwing off the layout (see #11165).
42+
mat-cell:first-of-type, mat-header-cell:first-of-type, mat-footer-cell:first-of-type {
4143
padding-left: $mat-row-horizontal-padding;
4244

4345
[dir='rtl'] & {
@@ -46,7 +48,7 @@ mat-cell:first-child, mat-header-cell:first-child, mat-footer-cell:first-child {
4648
}
4749
}
4850

49-
mat-cell:last-child, mat-header-cell:last-child, mat-footer-cell:last-child {
51+
mat-cell:last-of-type, mat-header-cell:last-of-type, mat-footer-cell:last-of-type {
5052
padding-right: $mat-row-horizontal-padding;
5153

5254
[dir='rtl'] & {
@@ -89,10 +91,12 @@ th.mat-header-cell, td.mat-cell, td.mat-footer-cell {
8991
border-bottom-style: solid;
9092
}
9193

92-
th.mat-header-cell:first-child, td.mat-cell:first-child, td.mat-footer-cell:first-child {
94+
// Note: we use `first-of-type`/`last-of-type` here in order to prevent extra
95+
// elements like ripples or badges from throwing off the layout (see #11165).
96+
th.mat-header-cell:first-of-type, td.mat-cell:first-of-type, td.mat-footer-cell:first-of-type {
9397
padding-left: $mat-row-horizontal-padding;
9498
}
9599

96-
th.mat-header-cell:last-child, td.mat-cell:last-child, td.mat-footer-cell:last-child {
100+
th.mat-header-cell:last-of-type, td.mat-cell:last-of-type, td.mat-footer-cell:last-of-type {
97101
padding-right: $mat-row-horizontal-padding;
98102
}

0 commit comments

Comments
 (0)