[英]Ionic 2 multiple ion-item in a row
I want to show 4 ion-items
in my ion-list
in a row. 我想在我的
ion-list
中连续显示4个ion-items
。
Since I'm using Bootstrap, I tried to do: 由于我使用的是Bootstrap,我试图这样做:
<button class="col-sm-3" ion-item *ngFor="let player of players">
<ion-avatar item-left>
<img [src]="user.photoURL">
</ion-avatar>
{{ user.name }}
</button>
but it didn't work. 但它不起作用。
You can manually set the width of each column by using the Explicit Column Percentage Attributes like this: 您可以使用显式列百分比属性手动设置每列的宽度,如下所示:
<ion-row>
<ion-col width-25>
<!-- item 1 -->
</ion-col>
<ion-col width-25>
<!-- item 2 -->
</ion-col>
<ion-col width-25>
<!-- item 3 -->
</ion-col>
<ion-col width-25>
<!-- item 4 -->
</ion-col>
</ion-row>
Or just add ion-col
dynamically, and they will expand to fill their row, and will resize to fit additional columns, like this: 或者只是动态添加
ion-col
,它们将展开以填充它们的行,并将调整大小以适应其他列,如下所示:
<ion-row>
<ion-col *ngFor="let player of players">
<ion-item>
<ion-avatar item-left>
<img [src]="user.photoURL">
</ion-avatar>
{{ user.name }}
</ion-item>
</ion-col>
</ion-row>
You can find more information about the Explicit Column Percentage Attributes here . 您可以在此处找到有关显式列百分比属性的更多信息。
UPDATE UPDATE
As of Ionic 3.0.0 , the way to achieve the same with the new grid would be something like this: 从Ionic 3.0.0开始 ,与新网格实现相同的方法将是这样的:
<ion-row>
<ion-col col-3>
<!-- item 1 -->
</ion-col>
<ion-col col-3>
<!-- item 2 -->
</ion-col>
<ion-col col-3>
<!-- item 3 -->
</ion-col>
<ion-col col-3>
<!-- item 4 -->
</ion-col>
</ion-row>
So the width-25
attribute needs to be replaced by col-3
. 所以
width-25
属性需要替换为col-3
。
Try: 尝试:
<ion-item>
<ion-row>
<ion-col *ngFor="let player of players">
<ion-avatar item-left>
<img [src]="user.photoURL">
</ion-avatar>
{{ user.name }}
</ion-col>
</ion-row>
</ion-item>
You dont really need bootstrap for this. 你真的不需要引导程序。 Check this tutorial and here
查看本教程和此处
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.