【发布时间】:2020-06-11 05:13:45
【问题描述】:
您好,我正在尝试使用 angular-flex 调整 UI 中的卡片。卡片的宽度根据其中的文本长度进行响应。但我希望每张卡片都具有相同的宽度,而与其中的内容无关。
如果我使用max-width,那么这会影响移动响应中的卡片。否则,在响应式视图中,所有卡片的大小和宽度都相同。
如果我使用的是display:grid;,那么这些卡片就是完美的。但是我需要使用 flex 来响应,所以我使用了display:flex;
这是用户界面:-
HTML :-
<div class="container">
<div class="cont">
<app-overview *ngFor="let item of data" [extra]="item.extra" [colorcode]="item.color" [ovrno]="item.value" [ovrtitle]="item.info" >
</app-overview>
</div>
</div>
CSS:-
.cont {
display: flex;
grid-template-columns: 1fr 1fr 1fr;
flex-direction: column;
flex-wrap: wrap;
}
@media (min-width: 900px) {
.cont {
flex-direction: row;
flex-wrap: wrap;
max-width: 100%;
margin: auto;
align-items: stretch;
}
}
-
无论内容长度如何,如何显示相同的卡片宽度?
PS:-另外,我想避免使用媒体查询。如何仅使用 flex 对不同的视图执行相同的操作?
- 还需要连续显示 3 张卡片。
编辑:-
应用概览组件:-
HTML:-
<div class="overview" [ngStyle]="getColor()" (click)="onSelect()">
<p class="no">{{no}}</p>
<p class="otitle">{{title}}</p>
</div>
CSS:-
.overview {
padding: 10px;
text-align: center;
border-radius: 10px;
color: #fff;
margin: 10px;
height: 270px;
cursor: pointer !important;
.no {
font-size: 6.5em;
font-weight: bold;
padding: 0.3em 0;
}
.otitle {
font-size: 25px !important;
font-weight: 300;
padding: 0.3em 0;
}
}
【问题讨论】:
标签: css angular-material angular-flex-layout