我试图让标签位于输入字段旁边。我尝试过使用花车,col和其他一些东西,但由于某种原因,他们不想听我的话!
请帮助你疯了。
我的HTML
<form class='form-group'>
<div class='container'>
<div class='row'>
<div class='col-6'>
<div class="form-group">
<label class='col-form-label formLabel'>Customer Name:</label>
<input class='form-control formInput' name='customerName' />
</div>
<div class="form-group">
<label class='formLabel'>Phone Number:</label>
<input class='form-control formInput' name='phoneNumber' />
</div>
<div class="form-group">
<label class='formLabel'>Email:</label>
<input class='form-control formInput' name='emailAddress' />
</div>
</div>
</div>
<div class='col-6'>
<div class="form-group">
<label class='col-form-label formLabel'>Customer Name:</label>
<input class='form-control formInput' name='customerName' />
<div class="form-group">
<label class='formLabel'>Phone Number:</label>
<input class='form-control formInput' name='phoneNumber' />
</div>
<div class="form-group">
<label class='formLabel'>Email:</label>
<input class='form-control formInput' name='emailAddress' />
</div>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button class='btn btn-success'>Save Changes</button>
</div>
</form>
https://www.bootply.com/b8B4C07XB7
可能的副本来自四年前。不同版本的bootstrap。
答案 0 :(得分:0)
只需在表单标记内添加form-inline类,即可看到魔法!
<form class="form-group form-inline">
<div class="container">
<div class="row">
<div class="col-6">
<div class="form-group">
<label class="col-form-label formLabel">Customer Name:</label>
<input class="form-control formInput" name="customerName">
</div>
</div>
</div>
</div>
</form>
答案 1 :(得分:0)
将form-inline
用于内联表单。它适用于大于768px的视口,因此将片段结果窗口展开到全屏以查看实际呈现的内联形式。
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css");
.formLabel {
text-align: left;
}
.formInput {
text-align: right;
}
<form class='form-inline'>
<div class="form-group">
<label class='col-form-label formLabel'>Customer Name:</label>
<input class='form-control formInput' name='customerName' />
</div>
<div class="form-group">
<label class='formLabel'>Phone Number:</label>
<input class='form-control formInput' name='phoneNumber' />
</div>
<div class="form-group">
<label class='formLabel'>Email:</label>
<input class='form-control formInput' name='emailAddress' />
</div>
<div class="form-group">
<label class='col-form-label formLabel'>Customer Name:</label>
<input class='form-control formInput' name='customerName' />
<div class="form-group">
<label class='formLabel'>Phone Number:</label>
<input class='form-control formInput' name='phoneNumber' />
</div>
<div class="form-group">
<label class='formLabel'>Email:</label>
<input class='form-control formInput' name='emailAddress' />
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button class='btn btn-success'>Save Changes</button>
</div>
</form>