ant-design/components/form/demo/advanced-search-form.md

114 lines
3.0 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 10
title: 高级搜索
---
2015-12-29 23:39:21 +08:00
三列栅格式的表单排列方式,常用于数据表格的高级搜索。
有部分定制的样式代码,由于输入标签长度不确定,需要根据具体情况自行调整。
````jsx
2016-04-12 14:55:02 +08:00
import { Form, Input, Row, Col, Button, DatePicker } from 'antd';
2015-12-29 23:39:21 +08:00
const FormItem = Form.Item;
ReactDOM.render(
<Form horizontal className="ant-advanced-search-form">
<Row gutter={16}>
<Col sm={8}>
<FormItem
label="搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
2016-05-19 15:21:48 +08:00
<Input placeholder="请输入搜索名称" size="default" />
</FormItem>
<FormItem
label="较长搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
<DatePicker size="default" />
</FormItem>
<FormItem
label="搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
2016-05-19 15:21:48 +08:00
<Input placeholder="请输入搜索名称" size="default" />
</FormItem>
</Col>
<Col sm={8}>
<FormItem
label="搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
2016-05-19 15:21:48 +08:00
<Input placeholder="请输入搜索名称" size="default" />
</FormItem>
<FormItem
label="较长搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
<DatePicker size="default" />
</FormItem>
<FormItem
label="搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
2016-05-19 15:21:48 +08:00
<Input placeholder="请输入搜索名称" size="default" />
</FormItem>
</Col>
<Col sm={8}>
<FormItem
label="搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
2016-05-19 15:21:48 +08:00
<Input placeholder="请输入搜索名称" size="default" />
</FormItem>
<FormItem
label="较长搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
<DatePicker size="default" />
</FormItem>
<FormItem
label="搜索名称"
labelCol={{ span: 10 }}
wrapperCol={{ span: 14 }}>
2016-05-19 15:21:48 +08:00
<Input placeholder="请输入搜索名称" size="default" />
</FormItem>
</Col>
</Row>
<Row>
<Col span={12} offset={12} style={{ textAlign: 'right' }}>
<Button type="primary" htmlType="submit">搜索</Button>
<Button>清除条件</Button>
</Col>
</Row>
</Form>
2015-12-29 23:39:21 +08:00
, mountNode);
````
````css
/* 定制样式 */
.ant-advanced-search-form {
2015-12-29 23:39:21 +08:00
padding: 16px 8px;
2015-12-29 23:43:10 +08:00
background: #f8f8f8;
2015-12-29 23:39:21 +08:00
border: 1px solid #d9d9d9;
border-radius: 6px;
}
/* 由于输入标签长度不确定,所以需要微调使之看上去居中 */
.ant-advanced-search-form > .row {
2016-02-25 18:03:48 +08:00
position: relative;
left: -6px;
2015-12-29 23:39:21 +08:00
}
.ant-advanced-search-form .ant-btn + .ant-btn {
2015-12-29 23:39:21 +08:00
margin-left: 8px;
}
````
<style>
2015-12-29 23:43:10 +08:00
#components-form-demo-advanced-search-form .ant-form-horizontal {
2015-12-29 23:39:21 +08:00
max-width: none;
}
</style>