twitter-bootstrap 单行 Bootstrap 3 上的多个输入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19075021/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 18:39:05  来源:igfitidea点击:

Multiple inputs on single line Bootstrap 3

csshtmltwitter-bootstraptwitter-bootstrap-3

提问by nathan

How can I get multiple inputs on a single line in a jumbotron with Bootstrap 3.

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

So it looks something like this: Find [dropdown list] in [text input] [Submit Button]

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

This is what I've currently got: http://jsfiddle.net/cTLwW/but I goes over 4 lines and each for input item is way to wide.

这是我目前所拥有的: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>

回答by devo

Try like this,

试试这样,

<!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

截屏

回答by Vikram

Try this

试试这个

<!DOCTYPE html>
<html>
    <head>
        <title>Bootstrap</title>        
        <link href="css/bootstrap.min.css" rel="stylesheet">        
  </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>
              </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="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>