简体   繁体   中英

direction : rtl doesn't work with angular material cards?

I'm using angular material cards and want to make text start from right to left , so i used direction: rtl; but it wasn't work . any help ? HTML Code :

<mat-card class="example-card">
   <mat-card-header>
     <div mat-card-avatar class="example-header-image"></div>
        <mat-card-title>
         <button class="profilrButton" (click)="viewProfile(post.uid)">{{post.fullName}}</button>
        </mat-card-title>
        <mat-card-subtitle>
          <p wrapper>{{post.title}} </p>
        </mat-card-subtitle>
      <mat-card-subtitle style="float: right;font-size: 8pt">{{arr[ind]['date']}}</mat-card-subtitle>
  </mat-card-header>

  <img mat-card-image src={{post.imageURL}} alt="Photo of a Shiba Inu">
  <mat-card-content>
     <p [class]="(hasArabic(post.description))? 'pre rtl':'pre'">
       {{post.description}}
     </p>
  </mat-card-content>
  <mat-card-actions>
     <button class="classA" (click)="approve(post.key,ind)" mat-button>Accept</button>
     <button class="classR" (click)="delete(post.key,ind)" mat-button>Reject</button>
  </mat-card-actions>
</mat-card>

CSS

.pre{
 white-space: pre-line;
}
.rtl{
 direction: rtl;
}

I believe Material uses the dir attribute more than the direction style. Try:

  <mat-card-content>
     <p [dir]="(hasArabic(post.description)) ? 'rtl' : 'auto'" class="pre">
       {{post.description}}
     </p>
  </mat-card-content>

You may also want to read up on the bidirectionality module but I think that is more for your own custom components that are used by Material components.

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