how to make the content inside the mat-card material 2 component scroll able ? I did not find anything on the material 2 website
This is not a built-in feature. To make the contents scrollable, set a height for <mat-card-content>
selector. Here is an example:
<mat-card>
<mat-card-header>
<mat-card-title>CARD TITLE</mat-card-title>
</mat-card-header>
<mat-card-content [style.overflow]="'auto'" [style.height.px]="'300'">
<p>
The Shiba Inu is the smallest of the six original and distinct
spitz breeds of dog from Japan. A small, agile dog that copes very
well with mountainous terrain, the Shiba Inu was originally bred
for hunting.
</p>
</mat-card-content>
<mat-card-actions>
<button mat-button>LIKE</button>
<button mat-button>SHARE</button>
</mat-card-actions>
</mat-card>
Link to StackBlitz demo.
You can leverage Flexbox to achieve this:
Add a class scrollable-content
to your mat-card
to make the content fill the card.
.mat-card.scrollable-content {
overflow: hidden;
display: flex;
flex-direction: column;
> .mat-card-title-group {
display: block;
}
> .mat-card-content {
overflow-y: auto;
}
}
<mat-card class="scrollable-content">
<!-- the rest of your inner html -->
</mat-card>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With