html - mat-card-content 中的段落溢出 mat-card 容器
问题描述
我刚开始使用角材料,但遇到了问题。我的段落会溢出卡片,但只有在文本较短时才会如此。如果我使用更大的段落,文本会很好地结束。这是我的代码
<mat-card *ngFor="let s of services">
<mat-card-header>
<mat-card-title> {{ s.title }} </mat-card-title>
<mat-card-subtitle> ${{ s.price }} </mat-card-subtitle>
</mat-card-header>
<img mat-card-image [src]="s.img" alt="" />
<mat-card-content>
<p>{{ s.description }}</p>
</mat-card-content>
<mat-card-actions>
<button mat-stroked-button color="accent">Learn more</button>
</mat-card-actions>
</mat-card>
请注意,角度材料文档提供的带有长段落的顶部卡片如何很好地包裹文本,但我添加的较短字符串却没有。我希望它无论如何都可以包装。
解决方案
用来CSS
实现
CSS FILE
.mat-card-content{
word-wrap: break-word;
}
TS File
import {Component, ViewEncapsulation} from '@angular/core';
@Component({
selector: 'card-fancy-example',
templateUrl: 'card-fancy-example.html',
styleUrls: ['card-fancy-example.css'],
encapsulation: ViewEncapsulation.None
})
export class CardFancyExample {}
工作stackblitz
示例:https ://stackblitz.com/edit/angular-zwqlyk?file=src/app/card-fancy-example.html
推荐阅读
- unity3d - Unity 如何从 Hashset 获取变换
- express - 用于检查输入类型的列表长度的自定义指令
- reactjs - 面临未处理的拒绝(错误):无效的挂钩调用。Hooks 只能在函数组件的主体内部调用
- git - Git - 如何在从裸存储库结帐期间排除 .gitignore 文件?
- javascript - 带有多个下拉子菜单的侧边栏未正确显示
- javascript - 使用 Nodejs 和 Reactjs 从一个 javascript 文件中访问另一个文件中的变量
- reactjs - 如何使用 reactJS/Javascript 从 AWS redshift 数据库中获取数据?
- javascript - 删除重复对象并将其数组元素与其他 Javascript 合并
- java - 如何删除android中底部工作表对话框片段创建的阴影?
- bash - 在jq中处理带有特殊字符的json对象