html - 如何响应地更改 Bootstrap 中 .input-group 的宽度?

标签 html css twitter-bootstrap

如何更改 .input-group 的宽度以使其更宽?我尝试设置 width: 50% 但这会在输入字段和按钮之间放置一个空格。

bootstrap

new-width

我也试过直接设置输入框的宽度,但也失败了。

bootstrap input 50%

并将其设置为超过 100%,这也失败了。

bootstrap input 110%

如果我将宽度设置为 300px 或 400px 看起来不错,但在移动设备上不行。

这是一个 Bootply http://www.bootply.com/HGr9b06Q1B

最佳答案

您需要将其包装在 Bootstrap 结构中...例如:

<div class="container">
  <div class="row">
    <div class="col-sm-4 col-sm-offset-4"><!--width is set by this div -->

      <div class="input-group">
        <input type="text" class="form-control" placeholder="Search for...">
        <span class="input-group-btn">
          <button class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
        </span>
      </div><!-- /input-group -->

    </div>
  </div>
</div>

参见 this fork of your bootply

哦,尽量不要使用 <center>元素,它已被弃用。

关于html - 如何响应地更改 Bootstrap 中 .input-group 的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29568914/

相关文章:

javascript - 检索图像的 HTML 元数据而不是下载图像

javascript - 是否有一个库允许我在页面底部加载 jQuery 但仍然用 $(function() {}) 填充我的 html

css - 如何在 webapp 或 yo angular 上更新和包含 Twitter Bootstrap 3?

css - 无法在 Angular 2 中正确显示 Bootstrap Carousel

jquery - 在链接标签中隐藏/显示文本,但在响应模式下不显示字体图标

javascript - 如果满足某些条件,如何在不调用模态的情况下先调用类?

css - 三列始终具有相同的大小和动态内容

php - 使用 CSS 和 file_get_contents 时根本不回显文本

html - CSS 中有没有一种方法可以让一个子元素指向一个父元素而不是一个元素?

php - twitter bootstrap 模态按按钮消失