简体   繁体   English

Ionic-标头图标与顶部对齐

[英]Ionic - Header icon is aligned to the top

I made a custom font icon using Fontastic to use in my Ionic project. 我使用Fontastic制作了一个自定义字体图标,以便在我的Ionic项目中使用。 When I applied the icon to the header as a button, the alignment seems to be off. 当我将图标作为按钮应用到标题时,对齐方式似乎已关闭。 But whenever I changed the icon to an icon from Ionicons it works just fine. 但是,每当我将图标从Ionicons更改为图标时,它都可以正常工作。 What am I doing wrong? 我究竟做错了什么?

I didn't apply any custom styles. 我没有应用任何自定义样式。

Here's what it looks like. 这是它的样子。

在此处输入图片说明

The icon on the right is the custom icon. 右侧的图标是自定义图标。 And it's being aligned to the top whereas an icon from Ionicons doesn't. 它与顶部对齐,而Ionicons的图标则没有。

EDIT: The code, 编辑:代码,

<ion-nav-title>Title</ion-nav-title>

<ion-nav-buttons side="right">
  <button class="button button-icon button-clear my-custom-icon-class" 
      ng-click="x.a">
  </button>
</ion-nav-buttons>

EDIT 2: 编辑2:

I tried both line-height and vertical-align:middle. 我尝试了line-height和vertical-align:middle。

Line-height does not change anything. 行高不变。 And vertical-align by default is set to "top". 默认情况下,垂直对齐设置为“顶部”。 Giving middle does not solve my problem and it breaks the ionic icons as well. 给中点不能解决我的问题,它也会破坏离子图标。 Note I'm overriding ionic's CSS. 注意我覆盖了ionic的CSS。 As it is, Ionic icons are working just fine. 实际上,离子图标运行正常。 It's my custom font that's breaking. 这是我的自定义字体坏了。

EDIT 3: 编辑3:

I'm wondering perhaps it has something to do with the SVG I created for making the font icon? 我想知道这是否与我为制作字体图标而创建的SVG有关? Is that possible? 那可能吗?

Use line-hight. 使用line-hight.

you can use line height to vertically align your icon. 您可以使用线高垂直对齐图标。

see this http://vanseodesign.com/css/vertical-centering/ 看到这个http://vanseodesign.com/css/vertical-centering/

NB: Sorry this is suppose to be a comment but I dont have enough reputation for that. NB:对不起,这应该是一个评论,但我对此没有足够的声誉。 :( :(

Try with vertical_align: middle; 尝试使用vertical_align: middle; . Look here vertical-align | 看这里垂直对齐| W3Schools W3学校

line-height is your option. 行高是您的选择。 Use firebug to see what suits you best. 使用萤火虫查看最适合您的软件。

http://www.w3schools.com/cssref/pr_dim_line-height.asp http://www.w3schools.com/cssref/pr_dim_line-height.asp

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

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