簡體   English   中英

如何在mat-option中使用mat-grid或grid列表,而不是使用CSS display grid

[英]How to use mat-grid or grid list inside mat-option instead of using css display grid

我的name和id都顯示在mat-option的兩行中,我在mat-option-list css中使用display:grid ,而我想使用mat-grid或grid-list屬性將它們顯示為grid。

<input matInput class="form-control input" [(ngModel)]="userTextvalue"matAutocomplete]="auto">
  <mat-autocomplete class="user-autocomplete" #auto="matAutocomplete">
    <mat-option-list *ngFor="let user of filteredUsers" [value]="user.name">
        <span class="username">{{user.name}}</span>
        <span class="usercode">{{user.code}}</span>
      </mat-option>
  </mat-autocomplete>

scss:

.mat-option-text {
  line-height: normal;
  display: grid;
}

[ 當前行為[1]

為什么不將所有包裝都包裹在包裝紙中?

   <mat-autocomplete #auto="matAutocomplete">
      <mat-option *ngFor="let option of options" [value]="option">
        <div class="wrapper">
          <span>{{option}}</span>
          <span>{{option}}</span>
        </div>
      </mat-option>
    </mat-autocomplete>

您的.css就像

.wrapper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

stackblitz

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM