gpt4 book ai didi

angular - 中没有足够的空间。如何添加多行

转载 作者:太空狗 更新时间:2023-10-29 17:46:02 24 4
gpt4 key购买 nike

我想在选项文本下添加描述选项的行。默认情况下,mat-select 限制字符数并在行尾添加“...”。我想要需要的多行选项。 stakckblitz 演示:https://stackblitz.com/edit/angular-wj9svw我的代码:

export class SelectOverviewExample {
foods: Food[] = [
{value: 'steak-0', viewValue: 'Steak longDescription longDescription longDescription longDescription longDescription'},
{value: 'pizza-1', viewValue: 'Pizza longDescription longDescription longDescription longDescription longDescription longDescription v v longDescription'},
{value: 'tacos-2', viewValue: 'Tacos'}
];
}

HTML:

<mat-form-field>
<mat-select placeholder="Favorite food">
<mat-option *ngFor="let food of foods" [value]="food.value">
{{food.viewValue}}
<b> some additional text text text text texttext </b>
</mat-option>
</mat-select>
</mat-form-field>

最佳答案

使用以下 CSS:

    .mat-select-panel mat-option.mat-option {
height: unset;
}

.mat-option-text.mat-option-text {
white-space: normal;
}

/deep/ .mat-select-panel mat-option.mat-option {
height: unset;
}

/deep/ .mat-option-text.mat-option-text {
white-space: normal;
}

示例演示在这里 - https://stackblitz.com/edit/angular-material2-issue-ndtstg

关于angular - <mat-select> 中没有足够的空间。如何添加多行 <mat-option>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52832889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com