css - 导航栏中的中心文本与 Ionic 框架中的图像

标签 css ionic-framework

我希望我的文本位于导航栏内图像的中间。我有这段代码,但文本与圆形图像水平对齐。非常感谢您的帮助。

<ion-header>
  <ion-navbar>
    <div *ngIf="showHeaderInfo">
      <ion-title>
        <div style="background-color: #4989ff; color: whitesmoke;" >
          <img class="circle-pic-header" style="margin-top: 5px; margin-left: 5px;" src="{{userInfo?.image}}" />
            {{ userInfo?.firstName }} {{ userInfo?.lastName }}
        </div>
      </ion-title>
    </div>
    <ion-buttons end>
      <button ion-button icon-only (click)="logOutHandler()">
        <ion-icon name="log-out"></ion-icon>
      </button>
    </ion-buttons>
  </ion-navbar>
</ion-header>

enter image description here

最佳答案

您可以在图像上添加 CSS 属性以像这样在中心垂直对齐文本

确保图像元素上没有显示: block

.circle-pic-header{vertical-align:middle}

You can find JSFiddle demo here

关于css - 导航栏中的中心文本与 Ionic 框架中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50096670/

相关文章:

css - Angularjs ng-class多类

javascript - Cordova 的电子邮件编辑器的过滤应用程序

javascript - 手动抛出错误ionic 2

html - Bootstrap btn 悬停不工作

javascript - 使用 D3.js 和 AngularJS 定制折线图

javascript - Ionic - Google 地方和自动填充位置

angular - ionic 幻灯片问题错误错误 : Uncaught (in promise): Error: Template parse errors:

html - 同时从左右两边减小div的宽度

html - 如何使标题以不同颜色显示

html - 如何在Chrome开发者工具中查看范围输入的拇指样式?