I have a list of ion-items with an icon followed by text. When the icon size is smaller as seen on the image below, the text seems to vertically align itself to the center of the ion-item
. But when the icon is bigger, the alignment is a bit off.
This is all I've added:
<ion-item>
<ion-icon class="icon ion-ios-clock-outline"></ion-icon>
Recent
</ion-item>
And the CSS:
.icon {
font-size: 35px;
color: #ffC977;
}
How can I fix this. I tried using vertical-align
, align-item
and align-self
. None of them worked.
5条答案
按热度按时间wswtfjt71#
试试看,在文本中添加一个
<span>
元素,vertical-align
只适用于并排内联的元素:CSS格式
HTML格式
6g8kf2rb2#
实际上,Ionic就是这样做的,但是你需要用
item-start
,item-end
等来告知元素的位置。只需如下设置代码:
ehxuflar3#
tyu7yeag4#
使用padding-verticalcss工具可以得到同样的结果。这里可以看到一个用于Ionic的css工具列表:https://ionicframework.com/docs/theming/css-utilities/
wnavrhmk5#
Please update your following CSS Class. Also you can move your text to a label tag and give the vertical-align middle for the label tag as well.
CSS
HTML