ant-design/components/layout/demo/top-side-2.md

107 lines
2.4 KiB
Markdown
Raw Normal View History

2017-02-27 23:39:16 +08:00
---
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
2022-05-23 14:37:16 +08:00
import { LaptopOutlined, NotificationOutlined, UserOutlined } from '@ant-design/icons';
import type { MenuProps } from 'antd';
2022-05-23 14:37:16 +08:00
import { Breadcrumb, Layout, Menu } from 'antd';
import React from 'react';
2018-06-27 15:55:04 +08:00
2017-02-27 23:39:16 +08:00
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}`,
};
}),
};
},
);
const App: React.FC = () => (
2017-02-27 23:39:16 +08:00
<Layout>
<Header className="header">
<div className="logo" />
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']} items={items1} />
2017-02-27 23:39:16 +08:00
</Header>
<Layout>
2019-12-26 12:21:08 +08:00
<Sider width={200} className="site-layout-background">
2017-02-27 23:39:16 +08:00
<Menu
mode="inline"
defaultSelectedKeys={['1']}
defaultOpenKeys={['sub1']}
2017-06-15 15:39:55 +08:00
style={{ height: '100%', borderRight: 0 }}
items={items2}
/>
2017-02-27 23:39:16 +08:00
</Sider>
<Layout style={{ padding: '0 24px 24px' }}>
2017-10-16 20:39:53 +08:00
<Breadcrumb style={{ margin: '16px 0' }}>
2017-02-27 23:39:16 +08:00
<Breadcrumb.Item>Home</Breadcrumb.Item>
<Breadcrumb.Item>List</Breadcrumb.Item>
<Breadcrumb.Item>App</Breadcrumb.Item>
</Breadcrumb>
2019-05-07 14:57:32 +08:00
<Content
2019-12-26 12:21:08 +08:00
className="site-layout-background"
2019-05-07 14:57:32 +08:00
style={{
padding: 24,
margin: 0,
minHeight: 280,
}}
2018-11-28 15:00:03 +08:00
>
2017-02-27 23:39:16 +08:00
Content
</Content>
</Layout>
</Layout>
</Layout>
2018-11-28 15:00:03 +08:00
);
export default App;
2019-05-07 14:57:32 +08:00
```
2017-02-27 23:39:16 +08:00
2019-05-07 14:57:32 +08:00
```css
2017-02-27 23:39:16 +08:00
#components-layout-demo-top-side-2 .logo {
float: left;
2017-02-27 23:39:16 +08:00
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;
2017-02-27 23:39:16 +08:00
}
2019-12-26 12:21:08 +08:00
.site-layout-background {
background: #fff;
}
2019-05-07 14:57:32 +08:00
```