简体   繁体   English

如何使用 Material 15.1.2 在 mat-nav-list 中将 mat-list-item 与 mat-icon 居中

[英]how to center mat-list-item with mat-icon in mat-nav-list with Material 15.1.2

I am having trouble getting my anchor text and icon to look centered with Material 15.1.2我无法让我的锚文本和图标看起来以 Material 15.1.2 为中心

My layout looks like this:我的布局如下所示:

<mat-sidenav-container>
  <mat-sidenav #sidenav role="navigation" [opened]="openSidenav">
    <mat-nav-list>
        <a mat-list-item routerLink="/signup">
          <mat-icon>face</mat-icon>
          <span matLine >Sign up</span>
        </a>

The final result looks like:最终结果如下所示: 在此处输入图像描述

I think the newer version is using flex where before it was using block.我认为较新的版本在使用 block 之前使用 flex。 It also seems that the icon is 24px but the enclosing box is slightly bigger at 31px.图标似乎也为 24px,但封闭框稍大一些,为 31px。
Trying to move the text with padding forces the whole block up and I can't move the anchor text up.尝试使用填充移动文本会强制整个块向上移动,我无法向上移动锚文本。

Any ideas?有任何想法吗?

I used display:inline-flex;我使用display:inline-flex; to center the text as in the code below (I have used bootstrap).按照下面的代码将文本居中(我使用了引导程序)。

<a mat-list-item routerLink="" >
    <div class="d-inline-flex">
        <mat-icon>face</mat-icon>
        <span matLine>Sign up</span>
    </div>
</a>

文本居中

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

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