Skip to content

Commit a394418

Browse files
crisbetojelbourn
authored andcommitted
fix(card): prevent content from overlapping footer (#5583)
* Prevents content from overlapping the `md-card-footer` component by making the footer `position: static`. * Uses content projection to ensure that the footer will always be at the bottom of a card. Fixes #5486.
1 parent 65d5efa commit a394418

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/lib/card/card.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
<ng-content></ng-content>
2+
<ng-content select="md-card-footer, mat-card-footer"></ng-content>

src/lib/card/card.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ $mat-card-header-size: 40px !default;
6262
}
6363

6464
.mat-card-footer {
65-
position: absolute;
66-
width: 100%;
67-
min-height: 5px;
68-
bottom: 0;
69-
left: 0;
65+
// The negative margins pulls out the element, countering the padding
66+
// to get the footer to be flush against the side of the card.
67+
$margin: -$mat-card-default-padding;
68+
69+
display: block;
70+
margin: 0 $margin $margin $margin;
7071
}
7172

7273
.mat-card-actions {
@@ -154,6 +155,11 @@ $mat-card-header-size: 40px !default;
154155
margin: -8px 0 0 0;
155156
}
156157

158+
.mat-card-footer {
159+
margin-left: -16px;
160+
margin-right: -16px;
161+
}
162+
157163
}
158164

159165
// FIRST/LAST CHILD ADJUSTMENTS
@@ -166,7 +172,8 @@ $mat-card-header-size: 40px !default;
166172

167173
// last els in mat-card-content and mat-card can't have their default margin-bottoms (e.g. <p> tags)
168174
// or they'll incorrectly add to card's bottom padding
169-
.mat-card > :last-child, .mat-card-content > :last-child {
175+
.mat-card > :last-child:not(.mat-card-footer),
176+
.mat-card-content > :last-child:not(.mat-card-footer) {
170177
margin-bottom: 0;
171178
}
172179

0 commit comments

Comments
 (0)