我正在使用bootstrap和laravel(刀片)作为后端,并且无法将我的代码上传到jdfiddle中以显示。但问题是标签远离输入框,是否可以将它放在中间?
<div class="row">
{{ Form::open(array('url' => 'bassengweb/insertHV', 'method' => 'POST')) }}
<div class="col-md-6">
<div class="form-group">
<label class="col-md-6 col-lg-6 control-label">Dato: </label>
<div class="col-md-6 col-lg-6">
{{ Form::text('Date', $date, array('class' => 'form-control')) }}
</div>
</div>
</div>
<div class="col-md-6 text-left-imp">
<div class="form-group">
<label class="col-md-6 col-lg-6 control-label">Tid: </label>
<div class="col-md-6 col-lg-6">
{{ Form::text('Time', $time, array('class' => 'form-control')) }}
</div>
</div>
</div>
</div>
答案 0 :(得分:6)
您的标签上有col-md-6
类,这会使它们相当宽。我尝试以下任何一种方法:
col-md-3
text-align: right
将其推送到输入旁边form-inline
或form-horizontal
,看看它是否能满足您的需求这是form-horizontal
类API sample中使用的标记(注意元素的排列方式):
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
</div>
</div>
</form>