2

我试图创建一个表单与Angular2 Material和引导电网, 我的HTML看起来像这样:Angular2材料MD-选择不与MD-输入内嵌

<div class="row"> 
    <div class="col-md-6 marign-top-10 margin-bottom-10"> 
     <md-input-container class="full-width"> 
      <input 
       mdInput 
       type="text" 
       formControlName="postal" 
       placeholder="Postal"> 
     </md-input-container> 
    </div> 

    <div class="col-md-6 marign-top-10 margin-bottom-10"> 
     <div class="full-width"> 
      <md-select class="full-width" placeholder="Country" formControlName="country_id"> 
       <md-option *ngFor="let country of countries" value="{{country.id}}">{{ country.name }}</md-option> 
      </md-select> 
     </div> 
    </div> 
</div> 

我全宽CSS类刚刚成立宽度:100%。

的问题是输入不是在同一条线上,因为它应该是 这里是几张截图:(我的应用程序是从右到左的语言,所以忽略文本方向)

input and select not in the same line

enter image description here

enter image description here

回答

0

它与MD-选择风格的问题,我曾在项目麻烦了,所以我的解决办法是:

CSS

md-select { 
    min-height: 30px; // or any value that equal md-input-container>input height 
} 

的jsfiddle example

+0

我复制了你的JSFiddle例子,现在我得到这个错误:“Error:md-input-container must包含一个mdInput指令。你忘了把mdInput添加到本地输入或者textarea元素中“ –

+0

因为我的例子是angular1,所以你应该继续使用angular2-material构造'' – Leguest

1

它是一个CSS问题,您可以添加到您的组件样式表:

.mat-select{ 
     margin-top:10px; 
} 

播放与价值可能大于10或更低