我试图设计一个引导表单,其中第一行有1个输入,第二行有2个输入。这是一张不起作用的照片,你可以看到我在做什么…
噢,我多么希望那些男孩能排得整齐!我已经盯着这个看太久了-感觉像是保证金问题,但我可能只是错过了一些明显的东西。
有人能发现我的错误吗?我把它归结为赤裸裸的:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<div class="container body-content"><br><br>
<form>
<div class="form-horizontal row">
<div class="form-group col-sm-12">
<label class="control-label col-sm-2">Supplier</label>
<div class="col-sm-10">
<input class="form-control"/>
</div>
</div>
<div class="row">
<div class="form-group col-sm-6">
<label class="control-label col-sm-4">Contact</label>
<div class="col-sm-8">
<input class="form-control"/>
</div>
</div>
<div class="form-group col-sm-6">
<label class="control-label col-sm-4">Phone</label>
<div class="col-sm-8">
<input class="form-control"/>
</div>
</div>
</div>
</div>
</form>
</div>
</body>
</html>
希望你能帮忙!
最佳答案
不要对表单控件应用列数,而是用所需列数将所有控件包装在<div>'s
中:
<div class="container body-content"><br><br>
<form>
<div class="form-horizontal">
<div class="col-sm-12">
<div class="form-group">
<label class="control-label col-sm-2">Supplier</label>
<div class="col-sm-10">
<input class="form-control"/>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="control-label col-sm-4">Contact</label>
<div class="col-sm-8">
<input class="form-control"/>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="control-label col-sm-4">Phone</label>
<div class="col-sm-8">
<input class="form-control"/>
</div>
</div>
</div>
</div>
</form>
这是一个现场演示
http://www.bootply.com/I5gUPVenbA