使用 Angular Material:这是选择框在选择输入后的行为方式
选择元素获得属性后text-size-adjust: 100%
是什么导致宽度变化。
您可以使用 codepen http://codepen.io/anon/pen/JNOdKP?editors=1000 进行检查
如何防止这种行为以保持固定宽度?
肮脏的修复是添加一堆
在 <div><div/>
就在</md-select>
之下代码(参见 codepen 中的最后一个示例)
最佳答案
不太脏的解决方案可能正在设置
ng-class="{'md-select-fixed-width': true}"
,当md-select-fixed-width: 140px;
所以即选择看起来像:
<md-select name="startYear4"
ng-model="ctrl.year4"
md-no-cache="ctrl.noCache"
ng-class="{'md-select-fixed-width':true}"
required>
<md-option ng-repeat="year4 in [2017, 2016, 2015]" value={{year4}} ng-bind="year4">{{year4}}</md-option>
</md-select>
和CSS:
.md-select-fixed-width {
width: 140px;
}
参见 codepen
关于html - Angular Material : Prevent layout resizing when select box value is chosen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43819116/