css - 如何将鼠标悬停在角度自动完成选项上
问题描述
我正在运行 Angular 应用程序,当我将鼠标悬停在自动完成垫选项上时,我有自动完成功能,我想查看整个客户编号和名称。我试着这样做
<mat-form-field [style.cursor]="pointer" [style.cursor]="pointer" [style.width.px]=300 >
<input class="selectCustomer" class="selectCustomerData" id="inputCustomer" matInput [matAutocomplete]="auto" [formControl]="customerFilterControl" [(ngModel)]="customerName">
<mat-icon matSuffix>keyboard_arrow_down</mat-icon>
<p id="spandiv">{{customerName}}</p>
<mat-autocomplete dropdown-arrow="true" panelWidth ="450px" #auto="matAutocomplete" [displayWith] = "displayFn">
<mat-option class="CustomerDropDown" *ngFor="let customer of filteredOptions | async" [value] ="customer.AccountID +' '+'('+ customer.AccountName + ')'" (onSelectionChange)="onCustomerChange(customer)">
{{customer.AccountID}} ({{customer.AccountName}}) <p id="spandiv1">{{customer.AccountID}} ({{customer.AccountName}})</p>
</mat-option>
</mat-autocomplete>
</mat-form-field>
基本上,当我将鼠标悬停在 mat-option 上时,我想看到价值
解决方案
一种简单的方法是将选项文本放在一个div
带有小max-width
. 然后设置该元素的样式,div
以便通常隐藏溢出,但在悬停选项文本时不会。
示例:https ://stackblitz.com/edit/angular-vzfpjy
此解决方案的一个问题是用户必须将鼠标悬停在选项文本上才能显示完整值。
推荐阅读
- css - 如何通过强制文本溢出使简单的预代码片段响应?
- windows - 如何用gnu替换win10的“ls”命令?
- css - 具有固定位置和宽度的响应式 Web 导航问题
- php - 如何在 WooCommerce 中更新产品属性分类标签名称
- yolo - 暗网:./src/utils.c:326:错误:断言“0”失败。(约洛夫4)
- python-3.x - 如何在python中使用assert打印值
- python - 使用 zlib 支持交叉编译 Python
- javascript - iframe 可以指定可以访问其 innerHTML、contentWindow、contentDocument 等的域的白名单吗?
- android - 一段时间后应用程序进入主屏幕而没有错误
- javascript - 如何使用 fetch polyfill、rollup 和 typescript 创建 umd 包?