html - 在 twitter bootstrap 的水平表单中内联表单?

在没有任何自制类的 twitter bootstrap 中设计一个看起来像这样的表单(请参阅下面的链接)的最佳方法是什么?

是否可以像下面的示例一样在表单水平内设置内部表单内联:

最佳答案

不要嵌套 <form>标签,这是行不通的。只需使用 Bootstrap 类。

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>

您可以通过多种方式实现该行为,这只是一个示例。在这个 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>

请注意,我使用的是 .form-inline.controls 中获得适当的样式.
您可以在 this 上进行测试jsfiddle

https://stackoverflow.com/questions/12201835/

相关文章:

html - 为什么单选按钮不能是 "readonly"?

html - 无法滚动到溢出容器的 flex 元素的顶部

css - 有没有办法使用 CSS 使子 DIV 的宽度比父 DIV 宽?

javascript - 禁用href标签

html - 如何使 HTML 表格的内容居中?

html - 使用开发者工具检查 webkit-input-placeholder

javascript - 获取文本输入字段中的光标位置(以字符为单位)

CSS div 元素 - 如何仅显示水平滚动条?

HTML 编码问题 - 显示 "Â"字符而不是 " "

jquery - 如何使用 css 或 jquery 在焦点上自动隐藏占位符文本?