角度材质:选择选择框值时,防止布局大小调整

时间:2017-05-06 10:01:58

标签: html css angularjs angular-material

使用角度材质:这是选择输入后选择框的行为方式 enter image description here
选择元素获取属性text-size-adjust: 100%之后导致宽度更改的原因。

您可以使用codepen http://codepen.io/anon/pen/JNOdKP?editors=1000

进行检查

如何防止此行为保持固定宽度?

&nbsp;代码下的<div><div/>中添加了</md-select>一堆肮脏的修补程序(参见codepen中的最后一个示例)

1 个答案:

答案 0 :(得分:2)

可能正在设置不太脏的解决方案 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

相关问题