本文介绍了在 twitter bootstrap 中的水平表单中内联表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在没有任何自制课程的情况下,在 twitter bootstrap 中设计这样的表单(请参阅下面的链接)的最佳方法是什么?
是否可以像下面的示例一样在表单水平内设置内部表单内联:
解决方案
不要嵌套
标签,那是行不通的.只需使用 Bootstrap 类.
引导程序 3
<div class="form-group"><label for="inputType" class="col-md-2 control-label">Type</label><div class="col-md-3"><input type="text" class="form-control" id="inputType" placeholder="Type">
<div class="form-group"><span class="col-md-2 control-label">元数据</span><div class="col-md-6"><div class="form-group row"><label for="inputKey" class="col-md-1 control-label">Key</label><div class="col-md-2"><input type="text" class="form-control" id="inputKey" placeholder="Key">
<label for="inputValue" class="col-md-1 control-label">Value</label><div class="col-md-2"><input type="text" class="form-control" id="inputValue" placeholder="Value">
</表单>
您可以通过多种方式实现这种行为,这只是一个示例.在这个 bootply
上进行测试引导程序 2
<div class="control-group"><label class="control-label" for="inputType">Type</label><div class="控件"><input type="text" id="inputType" placeholder="Type"><div class="control-group"><span class="control-label">元数据</span><div class="controls form-inline"><label for="inputKey">Key</label><input type="text" class="input-small" placeholder="Key" id="inputKey"><label for="inputValue">Value</label><input type="password" class="input-small" placeholder="Value" id="inputValue">
</表单>
请注意,我正在使用 .form-inline
在 .controls
中获取正确的样式.
您可以在 this jsfiddle
上对其进行测试What's the best way to design a form that looks like this (please see link below) in twitter bootstrap without any homemade classes ?
Is it possible to set a inner form-inline inside a form-horizontal like the below example:
解决方案
Don't nest <form>
tags, that will not work. Just use Bootstrap classes.
Bootstrap 3
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="inputType" class="col-md-2 control-label">Type</label>
<div class="col-md-3">
<input type="text" class="form-control" id="inputType" placeholder="Type">
</div>
</div>
<div class="form-group">
<span class="col-md-2 control-label">Metadata</span>
<div class="col-md-6">
<div class="form-group row">
<label for="inputKey" class="col-md-1 control-label">Key</label>
<div class="col-md-2">
<input type="text" class="form-control" id="inputKey" placeholder="Key">
</div>
<label for="inputValue" class="col-md-1 control-label">Value</label>
<div class="col-md-2">
<input type="text" class="form-control" id="inputValue" placeholder="Value">
</div>
</div>
</div>
</div>
</form>
You can achieve that behaviour in many ways, that's just an example. Test it on this bootply
Bootstrap 2
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputType">Type</label>
<div class="controls">
<input type="text" id="inputType" placeholder="Type">
</div>
</div>
<div class="control-group">
<span class="control-label">Metadata</span>
<div class="controls form-inline">
<label for="inputKey">Key</label>
<input type="text" class="input-small" placeholder="Key" id="inputKey">
<label for="inputValue">Value</label>
<input type="password" class="input-small" placeholder="Value" id="inputValue">
</div>
</div>
</form>
Note that I'm using .form-inline
to get the propper styling inside a .controls
.
You can test it on this jsfiddle
这篇关于在 twitter bootstrap 中的水平表单中内联表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-22 22:50