html - 将样式添加到 mat-autocomplete 的 mat-option

我有这个 HTML code here

<div style="width: 150px">
  <form class="example-form">
  <mat-form-field class="example-full-width">
    <input type="text" placeholder="Assignee" aria-label="Assignee" matInput [formControl]="myControl" [matAutocomplete]="auto">
    <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn">
      <mat-option *ngFor="let option of filteredOptions | async" [value]="option">
        {{option.name}}
      </mat-option>
    </mat-autocomplete>
  </mat-form-field>
</form>
</div>

mat-option 的默认行为是使用


  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis

  1. 我想将长句分成下一行而不是使用 ... 。样式不起作用:(

  2. 我还需要使用下面的代码覆盖我尝试过的字体,但它不会覆盖

mat-option {
    font-family: "Times New Roman", Times, serif; // does not work
  }

styling here

请帮忙。

最佳答案

您可以将其添加到您的 CSS 中:

.mat-option{
  word-wrap:break-word !important;
  white-space:normal !important;
  font-family: "Times New Roman", Times, serif;
}

.mat-option-text{
  line-height:initial !important;
}

https://stackoverflow.com/questions/67000746/

相关文章:

asp.net-core - 如何在 ASP.NET Core 3.1 中为 Swagger 指定默

ios - React native Pod 安装得到权限被拒绝

javascript - 使用 filter() 而不是 map() 来修改对象数组?

perl - 什么意思 "Can' t locate object method.."在这个使用 P

dart - 在 Dart 中,给定可空类型 `T?` ,我如何获得不可空类型 `T`

email - SendGrid Automated Security 如何处理 SPF 记录?

python - 在合并和排序函数中列出超出范围的索引

reactjs - 配置多个下一个插件 : withMDX, withBundleAnalyzer

.net-core - Cake Clean 任务在蛋糕构建时被跳过

c++ - 为什么C++语言的malloc函数前面要写指针类型?