2016-12-30 21:41:28 +08:00
|
|
|
---
|
|
|
|
order: 2
|
|
|
|
title:
|
|
|
|
zh-CN: 顶部-侧边布局
|
|
|
|
en-US: Header-Sider
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2017-02-27 23:39:16 +08:00
|
|
|
拥有顶部导航及侧边栏的页面,多用于展示类网站。
|
2016-12-30 21:41:28 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2017-02-27 23:39:16 +08:00
|
|
|
Both the top navigation and the sidebar, commonly used in documentation site.
|
2016-12-30 21:41:28 +08:00
|
|
|
|
2022-03-18 15:20:35 +08:00
|
|
|
```tsx
|
|
|
|
import { Layout, Menu, Breadcrumb, MenuProps } from 'antd';
|
2019-11-28 12:34:33 +08:00
|
|
|
import { UserOutlined, LaptopOutlined, NotificationOutlined } from '@ant-design/icons';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
const { Header, Content, Footer, Sider } = Layout;
|
2016-12-30 21:41:28 +08:00
|
|
|
|
2022-03-18 15:20:35 +08:00
|
|
|
const items1: MenuProps['items'] = ['1', '2', '3'].map(key => ({
|
|
|
|
key,
|
|
|
|
label: `nav ${key}`,
|
|
|
|
}));
|
|
|
|
|
|
|
|
const items2: MenuProps['items'] = [UserOutlined, LaptopOutlined, NotificationOutlined].map(
|
|
|
|
(icon, index) => {
|
|
|
|
const key = String(index + 1);
|
|
|
|
|
|
|
|
return {
|
|
|
|
key: `sub${key}`,
|
|
|
|
icon: React.createElement(icon),
|
|
|
|
label: `subnav ${key}`,
|
|
|
|
|
|
|
|
children: new Array(4).fill(null).map((_, j) => {
|
|
|
|
const subKey = index * 4 + j + 1;
|
|
|
|
return {
|
|
|
|
key: subKey,
|
|
|
|
label: `option${subKey}`,
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2022-04-03 23:27:45 +08:00
|
|
|
export default () => (
|
2016-12-30 21:41:28 +08:00
|
|
|
<Layout>
|
|
|
|
<Header className="header">
|
|
|
|
<div className="logo" />
|
2022-03-18 15:20:35 +08:00
|
|
|
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']} items={items1} />
|
2016-12-30 21:41:28 +08:00
|
|
|
</Header>
|
|
|
|
<Content style={{ padding: '0 50px' }}>
|
2017-10-16 20:39:53 +08:00
|
|
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
2016-12-30 21:41:28 +08:00
|
|
|
<Breadcrumb.Item>Home</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>List</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>App</Breadcrumb.Item>
|
|
|
|
</Breadcrumb>
|
2019-12-26 12:21:08 +08:00
|
|
|
<Layout className="site-layout-background" style={{ padding: '24px 0' }}>
|
|
|
|
<Sider className="site-layout-background" width={200}>
|
2016-12-30 21:41:28 +08:00
|
|
|
<Menu
|
|
|
|
mode="inline"
|
|
|
|
defaultSelectedKeys={['1']}
|
|
|
|
defaultOpenKeys={['sub1']}
|
2017-01-20 20:09:59 +08:00
|
|
|
style={{ height: '100%' }}
|
2022-03-18 15:20:35 +08:00
|
|
|
items={items2}
|
|
|
|
/>
|
2016-12-30 21:41:28 +08:00
|
|
|
</Sider>
|
2019-05-07 14:57:32 +08:00
|
|
|
<Content style={{ padding: '0 24px', minHeight: 280 }}>Content</Content>
|
2016-12-30 21:41:28 +08:00
|
|
|
</Layout>
|
|
|
|
</Content>
|
2019-05-07 14:57:32 +08:00
|
|
|
<Footer style={{ textAlign: 'center' }}>Ant Design ©2018 Created by Ant UED</Footer>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Layout>
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2016-12-30 21:41:28 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```css
|
2016-12-30 21:41:28 +08:00
|
|
|
#components-layout-demo-top-side .logo {
|
2020-10-26 12:17:07 +08:00
|
|
|
float: left;
|
2016-12-30 21:41:28 +08:00
|
|
|
width: 120px;
|
|
|
|
height: 31px;
|
2020-10-26 12:17:07 +08:00
|
|
|
margin: 16px 24px 16px 0;
|
|
|
|
background: rgba(255, 255, 255, 0.3);
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-row-rtl #components-layout-demo-top-side .logo {
|
|
|
|
float: right;
|
|
|
|
margin: 16px 0 16px 24px;
|
2016-12-30 21:41:28 +08:00
|
|
|
}
|
2019-12-26 12:21:08 +08:00
|
|
|
|
2022-04-22 15:00:18 +08:00
|
|
|
#components-layout-demo-top-side .site-layout-background {
|
2019-12-26 12:21:08 +08:00
|
|
|
background: #fff;
|
|
|
|
}
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|