css - 方向 : rtl doesn't work with angular material cards?

标签 css angular angular-material2

我正在使用 Angular Material 卡片,并且想让文本从右到左开始,所以我使用了 direction: rtl;但这是行不通的。 有帮助吗? HTML 代码:

<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;
}

最佳答案

我相信 Material 使用 dir 属性比 direction 样式更多。尝试:

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

您可能还想阅读 bidirectionality module但我认为这更适用于 Material 组件使用的您自己的自定义组件。

关于css - 方向 : rtl doesn't work with angular material cards?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53432324/

相关文章:

css - 在 Angular 指令中动态更改 CSS?

angular - 如何在Ionic 3 中显示捕获的图像预览?

angular - 如何在 Angular Material Table 单元格中显示一张或多张图像

angular - 有没有什么时候我不需要在组件中处理取消订阅的例子?

html - 交替行颜色 Angular Material 表

html - 列表样式类型为 : none; & list-style-position: inside; takes extra space in Firefox 的无序列表

html - 表中表

javascript - 在动画进行时暂停调度 NgRx Action

javascript - 放置亚马逊横幅 | Angular V4

html - 带有右对齐文本的 webkit TextArea 不显示空格字符