2015-07-07 11:25:16 +08:00
|
|
|
# 水平排列的表单
|
2015-06-15 20:24:01 +08:00
|
|
|
|
2015-07-07 23:45:46 +08:00
|
|
|
- order: 0
|
2015-06-15 20:24:01 +08:00
|
|
|
|
2015-06-16 09:54:10 +08:00
|
|
|
为 `<form>` 标签添加 `.ant-form-horizontal` 类(这让 `.ant-form-item` 表现为栅格系统中的 `row`),并结合使用我们提供的 [栅格系统](http://ant.design/components/layout/),可以实现 label 标签和表单控件的水平排列。
|
2015-06-15 20:24:01 +08:00
|
|
|
|
2015-07-07 11:25:16 +08:00
|
|
|
如需将一行静态文本和 `<label>` 标签置于同一行,则只需为 `<p>` 标签添加 `.ant-form-text` 类即可。
|
|
|
|
|
2015-07-07 23:45:46 +08:00
|
|
|
为 `label` 标签添加 `required` 属性,表示该项必选。
|
2015-07-07 11:25:16 +08:00
|
|
|
|
2015-07-17 15:12:48 +08:00
|
|
|
**注意**:对于表单域(`.ant-form-item`) 为静态文本、`checkbox`、`radio`以及`input[type="file"]`的,其高度不同于一般的表单域,需要在 `.ant-form-item` 类后再加上 `.ant-form-item-compact`。
|
|
|
|
|
2015-06-15 20:24:01 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
````html
|
|
|
|
<form class="ant-form-horizontal">
|
2015-07-17 15:12:48 +08:00
|
|
|
<div class="ant-form-item ant-form-item-compact">
|
2015-07-07 11:25:16 +08:00
|
|
|
<label for="userName" class="col-6" required>用户名:</label>
|
2015-07-09 13:48:49 +08:00
|
|
|
<div class="col-6">
|
2015-07-07 11:25:16 +08:00
|
|
|
<p class="ant-form-text">大眼萌 minion</p>
|
|
|
|
</div>
|
2015-06-15 20:24:01 +08:00
|
|
|
</div>
|
|
|
|
<div class="ant-form-item">
|
2015-07-07 11:25:16 +08:00
|
|
|
<label for="password" class="col-6" required>密码:</label>
|
2015-07-07 23:45:46 +08:00
|
|
|
<div class="col-14">
|
2015-07-07 11:25:16 +08:00
|
|
|
<input class="ant-input" type="password" id="password" placeholder="请输入密码"/>
|
2015-06-15 20:24:01 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-07-17 15:12:48 +08:00
|
|
|
<div class="ant-form-item ant-form-item-compact">
|
2015-07-07 11:25:16 +08:00
|
|
|
<label class="col-6" required>您的性别:</label>
|
2015-07-07 23:45:46 +08:00
|
|
|
<div class="col-14">
|
2015-07-07 11:25:16 +08:00
|
|
|
<label class="ant-radio-inline">
|
|
|
|
<input type="radio" name="radios" id="male-radio" value="male" checked> 男的
|
|
|
|
</label>
|
|
|
|
<label class="ant-radio-inline">
|
|
|
|
<input type="radio" name="radios" id="female-radio" value="female"> 女的
|
|
|
|
</label>
|
|
|
|
</div>
|
2015-07-16 14:18:03 +08:00
|
|
|
</div>
|
2015-07-07 11:25:16 +08:00
|
|
|
<div class="ant-form-item">
|
|
|
|
<label for="password" class="col-6" required>备注:</label>
|
2015-07-07 23:45:46 +08:00
|
|
|
<div class="col-14">
|
2015-07-07 11:25:16 +08:00
|
|
|
<textarea class="ant-input" placeholder="随便写"></textarea>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-07-17 15:12:48 +08:00
|
|
|
<div class="ant-form-item ant-form-item-compact">
|
2015-07-16 14:18:03 +08:00
|
|
|
<div class="col-14 col-offset-6">
|
2015-06-15 20:24:01 +08:00
|
|
|
<label>
|
2015-07-07 11:25:16 +08:00
|
|
|
<input type="checkbox"> 我是同意的
|
2015-06-15 20:24:01 +08:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-07-07 11:25:16 +08:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-16 col-offset-6">
|
2015-07-16 15:20:06 +08:00
|
|
|
<input type="submit" class="ant-btn ant-btn-primary" value="确 定" />
|
2015-07-07 11:25:16 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-06-15 20:24:01 +08:00
|
|
|
</form>
|
|
|
|
````
|