css - Is there a way to keep the content inside a mat-card responsive?
问题描述
Basically I have this mat-card
:
<mat-card>
<mat-card-content>
<div *ngFor="let siteSource of siteSources | paginate: { itemsPerPage: 5, currentPage: page};">
<site-details [site]='siteSource'></site-details>
</div>
</mat-card-content>
</mat-card>
And for each element I have this HTML
:
<div *ngIf="site" class="col-xs site-details">
<div>
<tr>
<td class="col-sm-6"><label>http://www.{{site._source.url}}.com.br</label></td>
<td class="col-sm-2">
<a routerLink="editSite/{{site._id}}" style="text-decoration: none; color: white"
routerLinkActive="active">
<button mat-raised-button color="primary">
Editar
</button>
</a>
</td>
<td class="col-sm-2"><button mat-raised-button color="warn"
(click)="openConfirmationDialog('excluir',site._source.url)">Excluir
</button></td>
<td class="col-sm-2"> <a target="_blank" href="http://www.{{site._source.url}}.com.br" title="Ir ao site"><button
mat-raised-button>Ir ao site</button></a>
</td>
</tr>
</div>
<hr>
</div>
<router-outlet></router-outlet>
The problem is that when I change to the mobile vision my buttons get out of the mat-card
:
Is there a way to keep the content inside the mat-card
equally responsive?
解决方案
有几件事正在发生
- 您正在使用不响应的 table (tr, td),为了响应,您必须使用 div
- 您使用的类是引导类,
<div>
如果您包含引导 CSS(我在 index.html 中所做的) ,它将使用它 col-sm-6 or col-sm-2
组合(来自 Bootstrap)不适用于 Angular 材质卡,因为该卡的最大宽度为 400 像素……而当col-sm
宽度在 576 像素 - 768 像素之间时应用网格类- 所以我们应用
col-[99]
类,因为宽度小于 576px - 我们可以为非常小的屏幕(card-fancy-example.css)覆盖填充和默认最小宽度,但这样的设计将不同于标准的角度材料设计
在此处查看演示- 注意:我删除了路由器插座只是为了避免为示例设置路由;
推荐阅读
- swift - 挣扎于基本的 Swift 逻辑(使用常量、变量和循环)
- postgresql - go-pg - 读取 upsert 后返回的 ID
- firebase - 在 github 操作上运行 firebase 模拟器
- r - 在 R 中带有警告的函数中抑制、记录和返回值
- android - 如何从 android Recognizer Intent 获取实时数据?
- svelte - Svelte 如何根据数字推入具有不同 props 的组件
- r - 如何使用 SQLite 存储函数
- java - 如何在属性文件中维护 Gradle 构建的项目和依赖项 jar 版本?
- c# - 在 C# 中正确覆盖异步方法
- airflow - Airflow dag 卡在运行状态