Mat-Chips连续显示5
我有一个Mat-Chips列表,我正在尝试通过倍数行显示它们。我想连续有5个芯片,而芯片的尺寸不增加(例如,有一个标准值,例如100px)。如果行上有一个元素,那将需要我不想要的整个宽度。我尝试了弹性的基础,但这是行不通的。我该怎么做?
HTML:
<div class="chip" fxLayoutAlign="flex-start">
<mat-form-field class="example-chip-list" appearance="fill">
<mat-label>Favorite Fruits</mat-label>
<mat-chip-list #chipList aria-label="Fruit selection">
<mat-chip *ngFor="let fruit of fruits" id="chip-item" (removed)="remove(fruit)">
{{fruit.name}}
<button matChipRemove>
<mat-icon>cancel</mat-icon>
</button>
</mat-chip>
</mat-chip-list>
</mat-form-field>
</div>
CSS:
.chip {
width: 100%;
flex-direction: row;
flex-wrap: wrap;
}
#chip-item {
flex: 1 0 25%;
}
I have a list of mat-chips and I'm trying to display them over multiples rows. I want to have 5 chips on a row and chip's size to don't increase (have a standard value, for example 100px). If there was one element on the row, it would take the whole width which I don't want. I tried with flex basis, but it's doesn't work. How can I do it?
HTML:
<div class="chip" fxLayoutAlign="flex-start">
<mat-form-field class="example-chip-list" appearance="fill">
<mat-label>Favorite Fruits</mat-label>
<mat-chip-list #chipList aria-label="Fruit selection">
<mat-chip *ngFor="let fruit of fruits" id="chip-item" (removed)="remove(fruit)">
{{fruit.name}}
<button matChipRemove>
<mat-icon>cancel</mat-icon>
</button>
</mat-chip>
</mat-chip-list>
</mat-form-field>
</div>
CSS:
.chip {
width: 100%;
flex-direction: row;
flex-wrap: wrap;
}
#chip-item {
flex: 1 0 25%;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论