我正在Ionic 2中开发购物车页面,我有以下代码,我正在尝试将按钮与文本垂直对齐在中间位置 . 我尝试使用vertical-align:middle CSS但没有成功 .
<ion-list>
<ion-item *ngFor="let product of this.productsCollection">
<ion-buttons end>
<button ion-button icon-only clear outline (click)="decreaseProduct()">
<ion-icon name="remove-circle"></ion-icon>
</button>
<span>{{this.quantityProducts}}</span>
<button ion-button icon-only clear outline (click)="increaseProduct()">
<ion-icon name="add-circle"></ion-icon>
</button>
</ion-buttons>
</ion-item>
上述代码的图像结果:https://i.stack.imgur.com/yfeL6.png
3 回答
没有CSS围绕你的元素很难分辨,但如果你的add / substract的容器有一个固定的高度并且是浮动的,你可以试试这样的东西 .
从那里你需要调整你的边距,以使它看起来不错,但这应该垂直对齐它们就好了 .
你可以在这里看到一个粗略的例子:JSFIDDLE
在_1872653中获得的解决方案:
IONIC 3:
通常,这是因为你的
ion-item
具有正确的height
但是button
不要button
因为它应该拉伸内部的图标 . 你可以看到我只留下左右边界的距离:'ve said now with the ispect function of chrome. So, to centered your icon you can try to remove it' spadding
和margin
:然后在你的代码中应用css: