css - Bootstrap 输入的父容器的完美 100% 宽度?

标签 css twitter-bootstrap

如何使 Bootstrap 输入字段与其父字段一样宽 100%?

正如 steve-obrien 在 Bootstrap Issue #1058 中所写的那样:

Setting to 100% does not work when applied directly to an input field as it does not take in to account the padding. So you end up with 100% of the container plus the padding on the input box, so the input box usually breaks outside its container.

那张票提供了各种解决方案,但我正在寻找最好的方法——最好是 Bootstrap 已经提供的 CSS 类。

最佳答案

应用 input-block-level 类对我来说效果很好,适用于各种屏幕宽度。它由 Bootstrap in mixins.less 定义如下:

// Block level inputs
.input-block-level {
  display: block;
  width: 100%;
  min-height: 28px;        // Make inputs at least the height of their button counterpart
  .box-sizing(border-box); // Makes inputs behave like true block-level elements
}

这与 his comment on issue #1058 中 'assembler' 建议的风格非常相似.

关于css - Bootstrap 输入的父容器的完美 100% 宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11232627/

相关文章:

css - 验证视差流体模板问题

html - Bootstrap 3 : input-group not work in chrome

javascript - 使用外部 JS 文件捕获 HTML 表单数据

html - 文本省略号到第一个跨度中的文本

html - 选择菜单填充但不移动下拉箭头

html - CSS 颜色未加载

javascript - 带有奇怪的 webkit 错误的响应式 header

css - 如何在 Bootstrap 3 中重叠列?

javascript - 如何在不刷新页面的情况下从 DOM 中删除前置/附加元素

html - 如何在移动方向更改时重置 Disqus 宽度