mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 13:18:04 +08:00
a67d39cd6c
* docs: Update Menu cn doc * chore: update ts def * chore: support convert * docs: more demo * docs: more demo * docs: all menu demos * docs: dropdown demo * docs: dropdown all demos * docs: update demo * test: coverage * docs: more demo * docs: layout demo * docs: all demo * chore: fix ts lint * docs: fix doc * docs: all docs
104 lines
2.4 KiB
Markdown
104 lines
2.4 KiB
Markdown
---
|
|
order: 2
|
|
title:
|
|
zh-CN: 顶部-侧边布局-通栏
|
|
en-US: Header Sider 2
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
同样拥有顶部导航及侧边栏,区别是两边未留边距,多用于应用型的网站。
|
|
|
|
## en-US
|
|
|
|
Both the top navigation and the sidebar, commonly used in application site.
|
|
|
|
```tsx
|
|
import { Layout, Menu, Breadcrumb, MenuProps } from 'antd';
|
|
import { UserOutlined, LaptopOutlined, NotificationOutlined } from '@ant-design/icons';
|
|
|
|
const { Header, Content, Sider } = Layout;
|
|
|
|
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}`,
|
|
};
|
|
}),
|
|
};
|
|
},
|
|
);
|
|
|
|
ReactDOM.render(
|
|
<Layout>
|
|
<Header className="header">
|
|
<div className="logo" />
|
|
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']} items={items1} />
|
|
</Header>
|
|
<Layout>
|
|
<Sider width={200} className="site-layout-background">
|
|
<Menu
|
|
mode="inline"
|
|
defaultSelectedKeys={['1']}
|
|
defaultOpenKeys={['sub1']}
|
|
style={{ height: '100%', borderRight: 0 }}
|
|
items={items2}
|
|
/>
|
|
</Sider>
|
|
<Layout style={{ padding: '0 24px 24px' }}>
|
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
|
<Breadcrumb.Item>Home</Breadcrumb.Item>
|
|
<Breadcrumb.Item>List</Breadcrumb.Item>
|
|
<Breadcrumb.Item>App</Breadcrumb.Item>
|
|
</Breadcrumb>
|
|
<Content
|
|
className="site-layout-background"
|
|
style={{
|
|
padding: 24,
|
|
margin: 0,
|
|
minHeight: 280,
|
|
}}
|
|
>
|
|
Content
|
|
</Content>
|
|
</Layout>
|
|
</Layout>
|
|
</Layout>,
|
|
mountNode,
|
|
);
|
|
```
|
|
|
|
```css
|
|
#components-layout-demo-top-side-2 .logo {
|
|
float: left;
|
|
width: 120px;
|
|
height: 31px;
|
|
margin: 16px 24px 16px 0;
|
|
background: rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.ant-row-rtl #components-layout-demo-top-side-2 .logo {
|
|
float: right;
|
|
margin: 16px 0 16px 24px;
|
|
}
|
|
|
|
.site-layout-background {
|
|
background: #fff;
|
|
}
|
|
```
|