css - Chrome和IE之间的Angular Material下拉菜单不同
问题描述
我有一个显示标志选择器和输入字段的自定义移动字段组件。
在Chrome中它看起来像这样。
选择折叠:
选择扩展:
在 IE 中:
我看到这是因为我将 MAT-SELECT 设置为width
40px,而 Material 的 CDK 覆盖将其设置min-width
为 40px。
但是 Chrome 似乎忽略了这一点,因为 IE 没有并强制执行此大小。
如何让 IE 像 Chrome 一样工作?
代码
参考:https ://material.angular.io/components/select/examples
<mat-form-field>
<mat-label>Favorite food</mat-label>
<mat-select style="width: 40px">
<mat-option *ngFor="let food of foods" [value]="food.value">
{{food.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
这不是我的组件,但它不相关。该问题存在于任何 mat-select 上。上面的关键行是mat-select style="width: 40px"。
许多在线代码宿主和测试在 IE 上不起作用(显然)。所以最好的测试方法就是你的材料链接,并通过检查器进行编辑。
解决方案
这段代码解决了我的问题。
参考: https ://github.com/angular/components/issues/17276 https://github.com/angular/components/issues/11609
/** IE 11 fixes */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
/** IE 11 fixes */
.cdk-overlay-pane {
display: block;
}
}
推荐阅读
- javascript - 如何将对象文字作为键值对推送到数组?
- c# - 创建一个 ImmutableArray 而不复制
- javascript - 使用 v8 在 R 中加载 Javascript 时出错
- r - data.table 上的加权差值计算
- vue.js - 如何让 Windows WebStorm 导入 Linux Vue webpack 项目
- c# - 类有两个构造函数
- linux - Linux文件缓存缓冲区是否属于某个页表段?
- java - 在 pom.xml 中添加的 json 依赖项得到错误
- node.js - 对承诺感到困惑
- java - java.lang.NullPointerException:尝试使用片段在空对象引用上调用接口方法“int java.util.List.size()”