简体   繁体   中英

Mat-toolbar content alignmnet

I want to have content aligned to left and right in this example.

https://material.angular.io/components/toolbar/examples

I want Icon on the left side, Text in the middle and username on the far right of the row.

How can I do this?

You can do the below to accomplish this.

Move the mat-icon to the top of the container to put it first.

 <mat-toolbar-row>
   <mat-icon class="example-icon">verified_user</mat-icon>

Apply example-spacer class to the text you want in the middle.

<span class="example-spacer">Second Line</span>

Add the following to the example-spacer class in toolbar-multirow-example.css

text-align: center;

User name after that

<span>User Name</span>

Stackblitz

https://stackblitz.com/edit/angular-tesmev?embed=1&file=app/toolbar-multirow-example.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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