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或更低