简体   繁体   English

我似乎无法更改我的 ion-item [ionic2] 中列的宽度

[英]I can’t seem to change the width of my columns inside my ion-item [ionic2]

 <ion-item-group *ngIf="tuesdayJson"> <ion-item-divider class="" sticky> {{tuesdayJson.dayOfWeek}} </ion-item-divider> <ion-item class="transparency" *ngFor="let event of tuesdayJson.agendaEvents"> <ion-row class="agenda-event-row {{event.rowType}}"> <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> </ion-item> </ion-item-group>

This is my code.这是我的代码。 I expect that when I add a width value to my ion-col tag, I'd get a certain width.我希望当我向 ion-col 标签添加宽度值时,我会得到一定的宽度。 In this case I want four equal columns.在这种情况下,我想要四个相等的列。

This is what I get:这就是我得到的: 在此处输入图片说明

Can someone please tell me what I am doing wrong?有人可以告诉我我做错了什么吗? The column width thing works for me perfectly fine inside ion-content but not inside ion-item.列宽对我来说在 ion-content 内部非常好,但在 ion-item 内部却没有。

Since the last update to Ionic 3 they've changed the way we use the grid.自上次更新 Ionic 3 以来,他们改变了我们使用网格的方式。 There's no more width-x attribute for <ion-col> . <ion-col>没有更多的width-x属性。 They changed to 12 cols grid scheme (much like the one in Bootstrap).他们改为 12 列网格方案(很像 Bootstrap 中的方案)。

So in this case your code needs to be like this:所以在这种情况下,你的代码需要是这样的:

<ion-row class="agenda-event-row {{event.rowType}}">
  <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>

If you need further explanation about the grid, screen sizes and everything else just see the Ionic 3 grid Docs .如果您需要有关网格、屏幕尺寸和其他所有内容的进一步说明,请参阅Ionic 3 网格文档

Hope this helps :D希望这会有所帮助:D

I may be late.我可能迟到了。 But considering being helpful for someone else, following way works for me in Ionic 4.但是考虑到对其他人有帮助,以下方式在 Ionic 4 中对我有用。

 <ion-grid> <ion-row> <ion-col size='2'> 1 of 3 (wider)(wider)(wider)(wider)(wider)(wider) </ion-col> <ion-col size='8'> 2 of 3 (wider)(wider)(wider)(wider)(wider)(wider) </ion-col> <ion-col size='2'> 3 of 3 (wider)(wider)(wider)(wider)(wider)(wider) </ion-col> </ion-row> </ion-grid>

But total of sizes is 12.但总尺寸为 12。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM