Luk*_*tor 6 css twitter-bootstrap-3 material-design angular-material
我正在尝试使用angular-material创建一个带有额外文本的输入.我想实现与bootstrap的.input-group-addon类似的效果:

我得到的最接近是这样:
<md-content layout-padding>
<div layout="row" class="md-whiteframe-z1" style="width: 40%">
<md-select placeholder="Type" ng-model="discount.type" flex="50" class="md-select-full-width">
<md-option value="AMOUNT">Amount</md-option>
<md-option value="PERCENT">Percent</md-option>
</md-select>
<div flex="50" layout="row" layout-align="center center">
<md-input-container flex>
<label>Value</label>
<input ng-model="discount.value">
</md-input-container>
<span>%</span>
</div>
</div>
</md-content>
Run Code Online (Sandbox Code Playgroud)
结果如下:

如您所见,2个字段未对齐.
我还试图用vertical-align的<span>%</span>,而不是layout-align="center center",但它似乎被忽略.
我想出了一个解决方案<md-icon>:
<md-content layout-padding>
<div layout="row" class="md-whiteframe-z1" style="width: 40%">
<md-select placeholder="Type" ng-model="discount.type" flex="50" class="md-select-full-width">
<md-option value="AMOUNT">Amount</md-option>
<md-option value="PERCENT">Percent</md-option>
</md-select>
<div flex="50" layout="row">
<md-input-container flex>
<label>Value</label>
<input ng-model="discount.value">
</md-input-container>
<md-icon md-font-set="regular-font">%</md-icon>
</div>
</div>
</md-content>
Run Code Online (Sandbox Code Playgroud)
这"regular-font"是一些不存在的图标字体库,以确保内部文本<md-icon>不会被解释为材料图标.
现在它很好地对齐:

你可以在这里看到工作解决方案:http://codepen.io/LukaszWiktor/pen/oXoqYg
| 归档时间: |
|
| 查看次数: |
4460 次 |
| 最近记录: |