css - 单行 Bootstrap 3 上的多个输入

标签 css html twitter-bootstrap twitter-bootstrap-3

如何使用 Bootstrap 3 在超大屏幕中的一行中获取多个输入。

所以它看起来像这样:在[文本输入] [提交按钮]中找到[下拉列表]

这是我目前得到的:http://jsfiddle.net/cTLwW/但是我超过了 4 行,每行输入项都太宽了。

  <div class="container jumbotron">
<h1><span class="text-center">Mywebsite.</span></h1>

<h2><span class="text-center">Find things close to you</span></h2>

<form class="form-horizontal" role="form" action="/" method="post">
  <div class="form-group">
    <span class="text-center"><label for="inputCity" class="col-lg-2 control-label">I
    need</label></span>

    <div class="col-lg-10">
      <span class="text-center"><select class="form-control">
        <option>
          Bakery
        </option>

        <option>
          Supermarket
        </option>

        <option>
          Etc
        </option>
      </select></span>
    </div>
  </div>

  <div class="row form-group">
    <span class="text-center"><label for="inputType" class=
    "col-lg-2 control-label">In</label></span>

    <div class="col-lg-8">
      <span class="text-center"><input type="text" class="form-control" id=
      "inputCity" placeholder="City"> <button type="submit" class=
      "btn btn-success"><span class="text-center">Go</span></button></span>
    </div>
  </div>
</form>

最佳答案

这样试试,

<!DOCTYPE html>
<html>
  <head>
    <title>Bootstrap 101 Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <style>
        label {
         font-weight: normal;
        }
       .jumbotron {
         line-height: 1.143;
        }
       label.col-lg-1 {
         width: 0;
       }
    </style>
  </head>
  <body>
    <div class="container jumbotron">
    <h1><span class="text-center">Mywebsite.</span></h1>

    <h2><span class="text-center">Find things close to you</span></h2>

    <form class="form-horizontal" role="form">
      <div class="form-group">
        <label for="inputCity" class="col-lg-2 control-label">Ineed</label>
        <div class="col-lg-3">
          <select class="form-control">
                <option>
                  Bakery
                </option>

                <option>
                  Supermarket
                </option>

                <option>
                  Etc
                </option>
              </select>
        </div>
        <label for="inputType" class="col-lg-1 control-label">In</label>
        <div class="col-lg-3">
          <input type="text" class="form-control" id="inputCity" placeholder="City"> 
        </div>
        <button type="submit" class="btn btn-success">Go</button>
      </div>
    </form>
  </div>



    <script src="//code.jquery.com/jquery.js"></script>
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
  </body>
</html>

Screen-shot

关于css - 单行 Bootstrap 3 上的多个输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19075021/

相关文章:

javascript - 获取语​​句不添加到数据库

javascript - 如何忽略页面上 iframe 的浏览器缩放(ctrl+scroll)

html - 对齐页眉和 Logo

html - 我的 fa fa-bars 没有显示 - 响应式顶部导航

jquery - 选项卡式 slider 轮播在 Bootstrap 4 中不起作用

javascript - Bootstrap : How to make panels auto collapse when clicking on another panel?

html - 在 CSS 页脚之前裁剪页面

css - 如何将一组内联 div 在另一个 div 中居中

html - 是否可以正确转义任意脚本标签内容?

javascript - Bootstrap datepicker 触发器更改