我遇到了bootstrap form-horizontal的问题,问题是我有一个带有两个“form-group col-sm-6”组的水平表单。
看起来两组之后有一个空格(请看蓝色箭头)。
我需要删除该空格,以便两个表单组填充空间。
我使用的代码是:
<!-- 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">
<section class="animated fadeInUp">
<div class="panel panel-default col-md-12">
<div class="panel-heading"> <b class="text-capitalize">CIF Profile</b>
<div class="actions pull-right"> <i class="fa fa-chevron-down"></i> </div>
</div>
<div class="panel-body">
<div class="form-horizontal col-sm-12" style="background-color:red;">
<div class="form-group col-sm-6" style="background-color:blue;">
<div class="col-sm-6">
<label class="control-label">Customer Id</label>
</div>
<div class="col-sm-6">
<input id="txtCustomerId" name="txtCustomerId" class="form-control" value="" maxlength="6" readonly="readonly">
</div>
</div>
<div class="form-group col-sm-6" style="background-color:white;">
<div class="col-sm-6">
<label class="control-label">Mnemonic</label>
</div>
<div class="col-md-6">
<input id="txtMnemonic" name="txtMnemonic" class="form-control" placeholder="" value="" maxlength="10">
</div>
</div>
</div>
</div>
</div>
</section>
答案 0 :(得分:0)
Bootstrap默认填充15px,只需添加此css,并删除form-group
.form-horizontal.col-sm-12 {
padding-left: 0px !important;
padding-right: 0px !important;
}
<!-- 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">
<section class="animated fadeInUp">
<div class="panel panel-default col-md-12">
<div class="panel-heading"> <b class="text-capitalize">CIF Profile</b>
<div class="actions pull-right"> <i class="fa fa-chevron-down"></i> </div>
</div>
<div class="panel-body">
<div class="form-horizontal col-sm-12" style="background-color:red;">
<div class="col-sm-6" style="background-color:blue;">
<div class="col-sm-6">
<label class="control-label">Customer Id</label>
</div>
<div class="col-sm-6">
<input id="txtCustomerId" name="txtCustomerId" class="form-control" value="" maxlength="6" readonly="readonly">
</div>
</div>
<div class="col-sm-6" style="background-color:white;">
<div class="col-sm-6">
<label class="control-label">Mnemonic</label>
</div>
<div class="col-md-6">
<input id="txtMnemonic" name="txtMnemonic" class="form-control" placeholder="" value="" maxlength="10">
</div>
</div>
<div>I see the red</div>
</div>
</div>
</div>
</section>