html - 如何在 Bootstrap 中将两个元素添加到一行中?

标签 html css twitter-bootstrap

我正在使用 Boostrap 同时学习和编码,我想的布局是这样的:

Row
  <SmallerColumn that hold label 1> <Larger Column that hold the control 1>
  <SmallerColumn that hold label 2> <Larger Column that hold the control 2>
EndRow

例如,一个组合框和一个标签,说明该组合框的用途。 例如:国家/地区:国家/地区组合框

最佳答案

bootstrap 的

form-horizo​​ntal 类就是您所需要的。然而,不同的行将由 form-group 类处理。但是使用 form-control 类会导致文本周围出现边框,如下所示:

form-control class

为了没有边框,使用control-label作为类。

试试这个代码:

<div class="form-horizontal">
  <div class="form-group">
    <label class="control-label col-sm-2">Islands:</label>
    <div class="col-sm-10">
    <label class="control-label" id="l1" >Combobox of Islands 1</label>
    </div>
  </div>
  <div class="form-group">
    <label class="control-label col-sm-2">Countries:</label>
    <div class="col-sm-10">
    <label class="control-label" id="l2" >Combobox of Countries 1</label>
    </div>
  </div>
</div>

这是一个jsfiddle:https://jsfiddle.net/mayank_shubham/an197vva/

关于html - 如何在 Bootstrap 中将两个元素添加到一行中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36579941/

相关文章:

html - CSS:将表格顶部对齐

html - 空的div被隐藏,没有任何内容,如何显示它但保持空?

html - 如何为特定页面缩放级别应用 CSS 规则?

animation - Airbnb.com 标志像动画

javascript - 如何在 Bootstrap 选项卡中禁用缓存 ajax 加载内容

javascript - 将xml嵌套到jquery中的无序列表中

html 和 css 格式化

html - div "style=resize:both"无法在 chrome 中缩小(但它在 firefox 中有效)

具有 block 宽度和滚动条的 Html 错误

切换模态后的javascript错误