如何使Bootstrap输入字段的宽度恰好与其父字段的宽度相同?
正如steve-obrien在Bootstrap Issue #1058中所写的那样
当直接应用于输入字段时,
设置为100%不起作用,因为它不考虑填充。所以你最终得到了100%的容器加上输入框上的填充,所以输入框通常会在它的容器之外断开。
这张票提供了各种解决方案,但我正在寻找最好的方法--最好是Bootstrap已经提供的CSS类。
发布于 2012-06-28 02:22:27
在不同的屏幕宽度上,应用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中的“汇编”所建议的风格非常相似。
发布于 2013-02-03 09:37:13
只需添加框大小:
input[type="text"] {
box-sizing: border-box;
}
发布于 2017-02-28 16:50:50
如果您使用的是C# ASP.NET MVC的默认模板,您可能会发现site.css覆盖了一些引导程序样式。如果你想使用Bootstrap,就像我一样,让M$覆盖这个(在你不知情的情况下)可能会让你非常沮丧!请随意删除任何不需要的样式...
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
https://stackoverflow.com/questions/11232627
复制相似问题