css - Ionic 2 和带有左右文本的 ion-item

标签 css ionic-framework ionic2

在 ionic 2 应用程序中,我只想创建一个可点击的 <ion-item>左侧和右侧都有文本的按钮。它适用于支票查看器(左侧为日期,右侧为金额)。

这看起来很简单,表面上也是如此。如前所述here你可以使用一些 CSS 将文本向左/向右推送。我发现它适用于大多数 View (例如手机),但在 iPad 上该元素显示效果不佳。

下面是我的代码和生成的 iPad 视觉效果的一些示例。有没有一种干净的方法可以做到这一点?

              <button ion-item *ngFor="let settlement of recentSettlements | slice:0:3" (click)="showSettlement(settlement)">
                <span class="floatLeft">{{settlement.checkDate.slice(0,10)}}</span>
                <span class="floatRight" [ngClass]="(settlement.checkTotal >= 0) ? 'positiveAmount' : 'negativeAmount'">${{settlement.checkTotal}}</span>            
              </button>

或者

              <button ion-item *ngFor="let settlement of recentSettlements | slice:0:3" (click)="showSettlement(settlement)">
                <ion-label item-start>{{settlement.checkDate.slice(0,10)}}</ion-label>
                <ion-label item-end [ngClass]="(settlement.checkTotal >= 0) ? 'positiveAmount' : 'negativeAmount'">${{settlement.checkTotal}}</ion-label>            
              </button>

enter image description here

enter image description here

最佳答案

你不需要接触CSS,你可以通过Ionic自己的指令来做到这一点:

<ion-list>
  <ion-item *ngFor="let n of whatever" (click)="doSmt(n)">
    <div item-left>Left</div>
    {{n.someProperty}}
    <div item-right>Right</div>
  </ion-item>

</ion-list>

来自文档:https://ionicframework.com/docs/components/#icon-list

关于css - Ionic 2 和带有左右文本的 ion-item,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43986857/

相关文章:

javascript - 我的蜘蛛网周围有一个奇怪的圆圈,我该如何修复它?

ios - iOS 上的 Ionic 应用程序意外关闭

node.js - 如何将模块(不在 npm 注册表中)安装到 ionic 项目?

ionic2 - Ionic 2 导入库

html - 显示背景图像 HTML2PDF

html - 将按钮放在我的页面中

html - 响应式标题问题

javascript - 在AngularJS ng-repeat中使用2个数组的数据

html - 如何设置 ionic 选项的默认选择值?

javascript - cordova 插件网络接口(interface)问题