twitter-bootstrap Bootstrap 输入组插件未内联

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25017903/
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 21:14:12  来源:igfitidea点击:

Bootstrap input group addon not inline

htmlcsstwitter-bootstrap

提问by J.Zil

This is my code: http://www.bootply.com/iR1SvOyEGH

这是我的代码:http: //www.bootply.com/iR1SvOyEGH

<form>
    <div class="form-group">
        <label for="inputEmail">Company Name</label>
  <input type="text" class="form-control">
  <span class="input-group-addon">.test.com</span>
    </div>
    <div class="form-group">
        <label for="inputPassword">Password</label>
        <input type="password" class="form-control" id="inputPassword" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-primary">Update</button>
</form>

My understanding is the input-group-addon should sit inline with the input box and be to the right but instead it sits below the input box taking up 100% width.

我的理解是 input-group-addon 应该与输入框内联并位于右侧,但它位于输入框下方,占据 100% 的宽度。

Can anyone please tell me where I have gone wrong.

谁能告诉我我哪里出错了。

回答by Bailey Herbert

The Bootstrap documentation states that the input-group-addonclass must be used within a input-group, while you are using a form-group.

引导程序文档指出input-group-addon类必须内使用input-group,而你正在使用form-group

   <form>
      <label for="inputEmail">Company Name</label>
      <div class="input-group">
          <input type="text" class="form-control">
          <span class="input-group-addon">.test.com</span>
      </div>
        <div class="form-group">
            <label for="inputPassword">Password</label>
            <input type="password" class="form-control" id="inputPassword" placeholder="Password">
        </div>
        <button type="submit" class="btn btn-primary">Update</button>
    </form>

See this for a demo: http://jsfiddle.net/TLtQU/3/

请参阅此演示:http: //jsfiddle.net/TLtQU/3/

EDIT:The input-group should not include the label, the label should be outside of the input-group for proper results.

编辑:输入组不应该包括标签,标签应该在输入组之外以获得正确的结果。