ank*_*tra 7 angular-material angular-material2 angular
如何使mat-card材料2组件内的内容滚动?我没有在材料2网站上找到任何东西
这不是内置功能.要使内容可滚动,请为<mat-card-content>选择器设置高度.这是一个例子:
<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>
Run Code Online (Sandbox Code Playgroud)
链接到StackBlitz演示.
您可以利用Flexbox实现以下目的:
scrollable-content在您的课程中添加一个课程,mat-card以使内容充实。
.mat-card.scrollable-content {
overflow: hidden;
display: flex;
flex-direction: column;
> .mat-card-title-group {
display: block;
}
> .mat-card-content {
overflow-y: auto;
}
}
Run Code Online (Sandbox Code Playgroud)
.mat-card.scrollable-content {
overflow: hidden;
display: flex;
flex-direction: column;
> .mat-card-title-group {
display: block;
}
> .mat-card-content {
overflow-y: auto;
}
}
Run Code Online (Sandbox Code Playgroud)