admin管理员组文章数量:1410717
Would it possible to write two inputs side by side? I am using matInput forms of Angular and i could not bring the 2nd input beside the 1st.
What I want to show is like: "input1 , input2" in the same line. Here is my code.
<div *ngIf="data.mod=='goLocation'" class="panel-body">
<form #f="ngForm" (ngSubmit)="go(f.value); f.reset();" class="settings-form">
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Longitude(X)" name="lon" id="lon" #lon="ngModel" ngModel required>
<mat-error *ngIf="lon.touched && lon.invalid">
<div *ngIf="lon.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Latitude(Y)" name="lat" id="lat" #lat="ngModel" ngModel required>
<mat-error *ngIf="lat.touched && lat.invalid">
<div *ngIf="lat.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
</table>
<button [disabled]="!f.valid" class="btn btn-outline-primary">Git</button>
</form>
</div>
Would it possible to write two inputs side by side? I am using matInput forms of Angular and i could not bring the 2nd input beside the 1st.
What I want to show is like: "input1 , input2" in the same line. Here is my code.
<div *ngIf="data.mod=='goLocation'" class="panel-body">
<form #f="ngForm" (ngSubmit)="go(f.value); f.reset();" class="settings-form">
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Longitude(X)" name="lon" id="lon" #lon="ngModel" ngModel required>
<mat-error *ngIf="lon.touched && lon.invalid">
<div *ngIf="lon.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Latitude(Y)" name="lat" id="lat" #lat="ngModel" ngModel required>
<mat-error *ngIf="lat.touched && lat.invalid">
<div *ngIf="lat.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
</table>
<button [disabled]="!f.valid" class="btn btn-outline-primary">Git</button>
</form>
</div>
Share
Improve this question
edited Mar 1, 2018 at 6:51
Bhuwan
16.9k5 gold badges37 silver badges60 bronze badges
asked Mar 1, 2018 at 6:47
MadMaxMadMax
3061 gold badge5 silver badges18 bronze badges
1
- I have tried using "col-sm-6" class of bootstrap before each <mat-form-field> and put them in a "container" but again it did not work. – MadMax Commented Mar 1, 2018 at 6:50
4 Answers
Reset to default 2The problem with your table is that you put 2 columns into 2 rows separately instead of 2 columns in 1 row, try like this:
<table>
<tr>
<td>1st column</td>
<td>2nd column</td>
</tr>
</table>
So this case, the 1st colum will inline next to 2nd column.
Try this.
<div *ngIf="data.mod=='goLocation'" class="panel-body">
<form #f="ngForm" (ngSubmit)="go(f.value); f.reset();" class="settings-form">
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Longitude(X)" name="lon" id="lon"
#lon="ngModel" ngModel required>
<mat-error *ngIf="lon.touched && lon.invalid">
<div *ngIf="lon.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
<td>
<mat-form-field>
<input matInput placeholder="Latitude(Y)" name="lat" id="lat"
#lat="ngModel" ngModel required>
<mat-error *ngIf="lat.touched && lat.invalid">
<div *ngIf="lat.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
</table>
<button [disabled]="!f.valid" class="btn btn-outline-primary">Git</button>
</form>
</div>
<div *ngIf="data.mod=='goLocation'" class="panel-body">
<form #f="ngForm" (ngSubmit)="go(f.value); f.reset();" class="settings-form">
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Longitude(X)" name="lon" id="lon"
#lon="ngModel" ngModel required>
<mat-error *ngIf="lon.touched && lon.invalid">
<div *ngIf="lon.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
<td>
<mat-form-field>
<input matInput placeholder="Latitude(Y)"
name="lat" id="lat"
#lat="ngModel" ngModel required>
<mat-error *ngIf="lat.touched &&
lat.invalid">
<div *ngIf="lat.errors.required">Bu
alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
<tr>
</tr>
</table>
<button [disabled]="!f.valid" class="btn btn-outline-
primary">Git</button>
</form>
</div>
Try to wrap both the button
's td
into a single tr
.
Stack Snippet
<div *ngIf="data.mod=='goLocation'" class="panel-body">
<form #f="ngForm" (ngSubmit)="go(f.value); f.reset();" class="settings-form">
<table>
<tr>
<td>
<mat-form-field>
<input matInput placeholder="Longitude(X)" name="lon" id="lon" #lon="ngModel" ngModel required>
<mat-error *ngIf="lon.touched && lon.invalid">
<div *ngIf="lon.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
<td>
<mat-form-field>
<input matInput placeholder="Latitude(Y)" name="lat" id="lat" #lat="ngModel" ngModel required>
<mat-error *ngIf="lat.touched && lat.invalid">
<div *ngIf="lat.errors.required">Bu alanı boş geçemezsiniz.</div>
</mat-error>
</mat-form-field>
</td>
</tr>
</table>
<button [disabled]="!f.valid" class="btn btn-outline-primary">Git</button>
</form>
</div>
本文标签: javascriptshowing two inputs side by sideStack Overflow
版权声明:本文标题:javascript - showing two inputs side by side - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744811053a2626432.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论