Using Angular Material (version 10), I would like to animate a mat-card
so that it vertically expands to its full height when the page loads.
I have tried some tests just with the hover event (if this works, I will then work on how to apply the transition upon page load - this is another story), with the following CSS:
.test-anim {
height: 0!important;
transition: height 2s ease !important;
&:hover {
height: 100% !important;
}
}
<mat-card class="test-anim">
[some content...]
</mat-card>
Unfortunately this does not work:
when I hover the
mat-card
, the card expends directly from 0 to 100%, but with no transition at all. And btw, when I try to set the height manually from Chrome Developer Tools, I realize that any intermediate percentage (e.g. 50%) seems to be taken as 100%. Only 0% makes a difference with 100%. (However, the animation works with opacity instead of height, and replacing 100% with 1).I cannot use
px
values in the transition, because the actual height of the mat-card could vary depending on the data being displayed.even though I would use
px
values for the transition, it would still not fully work: when I manually set the height in pixels (eg '30px') from Chrome Developer Tools, the card itself is actually sized properly, BUT its content is displayed outside of the card (I would have expected some kind of clipping of themat-card
content, by themat-card
itself).
Could you please help me? Many thanks!