视口大小较小时,表单字段会重叠。当空间不够时,表单字段是否可以在下一行捕捉?
代码段:
<form class="compact">
<div class="row">
<div class="col-xs-6">
<section class="form-block">
<div class="form-group">
<label for="aForm_1">This is a form field</label>
<input type="text" id="aForm_1" placeholder="Enter value here" size="45">
</div>
</section>
</div>
<div class="col-xs-6">
<section class="form-block">
<div class="form-group">
<label for="aForm_2">Overlapping Text</label>
<input type="text" id="aForm_2" placeholder="Enter value here" size="45">
</div>
</section>
</div>
</div>
</form>
以下是plunker: https://embed.plnkr.co/ynfi39fIMk1bc8bSBHAp/
答案 0 :(得分:5)
@ X.Vu:请看一下这个Plnkr:https://plnkr.co/edit/6YhGmFusvo5EdySzxNpn?p=preview
以及网格文档中的Clarity Forms: https://vmware.github.io/clarity/documentation/forms
您需要按照文档中的说明添加.row
类.form-group
,然后在表单字段中使用.col-*
类。
<form class="compact">
<section class="form-block">
<div class="form-group row">
<div class="col-md-2 col-sm-6 col-xs-12">
<label for="aForm_1">This is a form field</label>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<input type="text" id="aForm_1" class="form-control" placeholder="Enter value here" size="45">
</div>
<div class="col-md-2 col-sm-6 col-xs-12">
<label for="aForm_2">Overlapping Text</label>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<input type="text" id="aForm_2" class="form-control" placeholder="Enter value here" size="45">
</div>
</div>
</section>
</form>
另请注意,我在.form-control
上添加了input
课程,因为input
占据了分配给它的整个.col-*
空间。