[英]bootstrap form-control and grid
What am I missing here? 我在这里想念什么?
Not only are my labels on top of my input field but the input field is as wide as the page. 我的标签不仅在输入字段的顶部,而且输入字段的宽度与页面一样大。
[UPDATED with improved code] [使用改进的代码进行了更新]
<form class="form-horizontal" #scheduleWorkForm="ngForm">
<div class="form-group">
<label class="control-label col-md-3" for="averageHoursWorkedPerWeek">{{ 'RequestTimeOff.AvgHoursWorked' | translate }}</label>
<div class="col-md-5">
<input class="form-control col-md-5" type="number" [numRange]="{ min: 1, max: 140 }" [(ngModel)]="incident.schedule.averageHoursWorkedPerWeek" name="averageHoursWorkedPerWeek" />
</div>
</div>
When I examine the rendered CSS, I see that div.form-control width is set explicitly to 100%, but div.col-md-x has no width specified. 当我检查渲染的CSS时,我看到div.form-control宽度明确设置为100%,但是div.col-md-x没有指定宽度。
You're not nesting the .form-control
properly; 您没有正确嵌套.form-control
; instead of combining that class with the Bootstrap Grid, you need to nest it within a Grid wrapper: 而不是将该类与Bootstrap Grid结合在一起,您需要将其嵌套在Grid包装器中:
<form class="form-horizontal" #scheduleWorkForm="ngForm">
<div class="form-group">
<label class="control-label col-md-3" for="averageHoursWorkedPerWeek">{{ 'RequestTimeOff.AvgHoursWorked' | translate }}</label>
<div class="col-md-5">
<input class="form-control col-md-5" type="number" [numRange]="{ min: 1, max: 140 }" [(ngModel)]="incident.schedule.averageHoursWorkedPerWeek" name="averageHoursWorkedPerWeek" />
</div>
</div>
You can see more examples of how .form-horizontal
interacts with .form-group
and .form-control
here: https://getbootstrap.com/docs/3.3/css/#forms-horizontal 您可以在此处查看有关.form-horizontal
如何与.form-group
和.form-control
交互的更多示例: https : //getbootstrap.com/docs/3.3/css/#forms-horizontal
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.