各个表单控件会通过 Bootstrap 自动接收一些全局样式。
所有带有 class="form-control" 的文本 <input>、<textarea> 和 <select> 元素都设置为 width: 100%;默认情况下。
所有三种表单布局的标准规则:
<div class="form-group">
(最佳间距所需).form-control
对所有文本<input>
,<textarea>
, 和<select>
元素以下示例创建一个简单的 Bootstrap 表单,其中包含两个输入字段、一个复选框和一个提交按钮:
<form>
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
亲自试一试 »
Class | Description | Example |
---|---|---|
.form-inline | Makes a <form> left-aligned with inline-block controls (This only applies to forms within viewports that are at least 768px wide) | 尝试一下 |
.form-horizontal | Aligns labels and groups of form controls in a horizontal layout | 尝试一下 |
.form-control | Used on input, textarea, and select elements to span the entire width of the page and make them responsive | 尝试一下 |
.form-control-feedback | Form validation class | 尝试一下 |
.form-control-static | Adds plain text next to a form label within a horizontal form | 尝试一下 |
.form-group | Container for form input and label | 尝试一下 |
Class | Description | Example |
---|---|---|
.input-group | Container to enhance an input by adding an icon, text or a button in front or behind it as a "help text" | 尝试一下 |
.input-group-lg | Large input group | 尝试一下 |
.input-group-sm | Small input group | 尝试一下 |
.input-group-addon | Together with the .input-group class, this class makes it possible to add an icon or help text next to the input field | 尝试一下 |
.input-group-btn | Together with the .input-group class, this class attaches a button next to an input. Often used as a search bar | 尝试一下 |
.input-lg | Large input field | 尝试一下 |
.input-sm | Small input field | 尝试一下 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!