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

102 lines
2.8 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.
2019-05-07 14:57:32 +08:00
```jsx
use ant design icons 4.0 (#18217) * feat: use @ant-design/icons@4.0 * feat: use createFromIconfontCN to make site works * feat: update doc for Icon * feat: use icon in component Alert * feat: use icon in component Avatar * feat: use icon in component Breadcrumb * feat: use icon in component Button * feat: use icon in component Cascader * feat: use icon in component Collapse * feat: use icon in component Datepicker * feat: use icon in component Dropdown * feat: use icon in component Form * feat: use icon in component Input * feat: use icon in component InputNumber * feat: use icon in component Layout * feat: use icon in component Mention * feat: use icon in component Message * feat: use icon in component Modal * feat: use icon in component Notification * feat: use icon in component PageHeader * feat: use icon in component Pagination * feat: use icon in component Popconfirm * feat: use icon in component Progress * feat: use icon in component Rate * feat: use icon in component Result * feat: use icon in component Select * feat: use icon in component Step * feat: use icon in component Switch * feat: use icon in component Table * feat: use icon in component Tab * feat: use icon in component Tag * feat: handle rest component which using Icon * fix: remove unused vars * feat: use latest alpha ant design icons * fix: failed test in uploadlist.test.js * test: update snapshot for icons * doc: add Icon for site * doc: use @ant-design/icons in site * chore: use latest icons * fix: tslint issue * fix: test cases * fix: types for react * fix: lint rules for import orders * fix: use @ant-design/icons@4.0.0-alpha.5 to avoid insert css in server render * fix: eslint error in demo/**.md * inject antd icons * update snapshot * fix site * doc: update docs * fix: code snippets icon in site * feat: use latest @ant-design/icons * fix: icon props in message
2019-08-13 14:07:17 +08:00
import { Layout, Menu, Breadcrumb } from 'antd';
import { UserOutlined, LaptopOutlined, NotificationOutlined } from '@ant-design/icons';
2018-06-27 15:55:04 +08:00
2017-02-27 23:39:16 +08:00
const { SubMenu } = Menu;
const { Header, Content, Sider } = Layout;
ReactDOM.render(
<Layout>
<Header className="header">
<div className="logo" />
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['2']}>
2017-02-27 23:39:16 +08:00
<Menu.Item key="1">nav 1</Menu.Item>
<Menu.Item key="2">nav 2</Menu.Item>
<Menu.Item key="3">nav 3</Menu.Item>
</Menu>
</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 }}
2017-02-27 23:39:16 +08:00
>
2020-04-27 23:42:51 +08:00
<SubMenu key="sub1" icon={<UserOutlined />} title="subnav 1">
2017-02-27 23:39:16 +08:00
<Menu.Item key="1">option1</Menu.Item>
<Menu.Item key="2">option2</Menu.Item>
<Menu.Item key="3">option3</Menu.Item>
<Menu.Item key="4">option4</Menu.Item>
</SubMenu>
2020-04-27 23:42:51 +08:00
<SubMenu key="sub2" icon={<LaptopOutlined />} title="subnav 2">
2017-02-27 23:39:16 +08:00
<Menu.Item key="5">option5</Menu.Item>
<Menu.Item key="6">option6</Menu.Item>
<Menu.Item key="7">option7</Menu.Item>
<Menu.Item key="8">option8</Menu.Item>
</SubMenu>
2020-04-27 23:42:51 +08:00
<SubMenu key="sub3" icon={<NotificationOutlined />} title="subnav 3">
2017-02-27 23:39:16 +08:00
<Menu.Item key="9">option9</Menu.Item>
<Menu.Item key="10">option10</Menu.Item>
<Menu.Item key="11">option11</Menu.Item>
<Menu.Item key="12">option12</Menu.Item>
</SubMenu>
</Menu>
</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>
2018-06-27 15:55:04 +08:00
</Layout>,
2019-05-07 14:57:32 +08:00
mountNode,
2018-11-28 15:00:03 +08:00
);
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
```