2016-05-16 10:58:34 +08:00
|
|
|
---
|
|
|
|
order: 4
|
|
|
|
title: 可收起展开的侧边导航
|
|
|
|
---
|
|
|
|
|
|
|
|
页面横向空间有限时使用。侧边导航默认收起,点击底部按钮时展开。
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Menu, Breadcrumb, Icon } from 'antd';
|
2016-05-27 11:48:08 +08:00
|
|
|
import BrowserDemo from 'site/theme/template/BrowserDemo';
|
2016-05-16 10:58:34 +08:00
|
|
|
const SubMenu = Menu.SubMenu;
|
|
|
|
|
|
|
|
const AsideCollapse = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
collapse: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
onCollapseChange() {
|
|
|
|
this.setState({
|
|
|
|
collapse: !this.state.collapse,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
const collapse = this.state.collapse;
|
|
|
|
return (
|
2016-12-23 17:58:37 +08:00
|
|
|
<div className={collapse ? "layout-aside layout-aside-collapse" : "layout-aside"}>
|
|
|
|
<aside className="layout-sider">
|
|
|
|
<div className="layout-logo"></div>
|
2016-05-16 10:58:34 +08:00
|
|
|
<Menu mode="inline" theme="dark" defaultSelectedKeys={['user']}>
|
|
|
|
<Menu.Item key="user">
|
2016-11-30 10:54:42 +08:00
|
|
|
<Icon type="user" />
|
|
|
|
{!collapse && <span className="nav-text">导航一</span>}
|
2016-05-16 10:58:34 +08:00
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Item key="setting">
|
2016-11-30 10:54:42 +08:00
|
|
|
<Icon type="setting" />
|
|
|
|
{!collapse && <span className="nav-text">导航二</span>}
|
2016-05-16 10:58:34 +08:00
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Item key="laptop">
|
2016-11-30 10:54:42 +08:00
|
|
|
<Icon type="laptop" />
|
|
|
|
{!collapse && <span className="nav-text">导航三</span>}
|
2016-05-16 10:58:34 +08:00
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Item key="notification">
|
2016-11-30 10:54:42 +08:00
|
|
|
<Icon type="notification" />
|
|
|
|
{!collapse && <span className="nav-text">导航四</span>}
|
2016-05-16 10:58:34 +08:00
|
|
|
</Menu.Item>
|
|
|
|
<Menu.Item key="folder">
|
2016-11-30 10:54:42 +08:00
|
|
|
<Icon type="folder" />
|
|
|
|
{!collapse && <span className="nav-text">导航五</span>}
|
2016-05-16 10:58:34 +08:00
|
|
|
</Menu.Item>
|
|
|
|
</Menu>
|
2016-12-23 17:58:37 +08:00
|
|
|
<div className="aside-action" onClick={this.onCollapseChange}>
|
2016-05-16 10:58:34 +08:00
|
|
|
{collapse ? <Icon type="right" /> : <Icon type="left" />}
|
|
|
|
</div>
|
|
|
|
</aside>
|
2016-12-23 17:58:37 +08:00
|
|
|
<div className="layout-main">
|
|
|
|
<div className="layout-header"></div>
|
|
|
|
<div className="layout-container">
|
2016-05-16 10:58:34 +08:00
|
|
|
<Breadcrumb>
|
|
|
|
<Breadcrumb.Item>首页</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>应用列表</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>某应用</Breadcrumb.Item>
|
|
|
|
</Breadcrumb>
|
2016-12-23 17:58:37 +08:00
|
|
|
<div className="layout-content">
|
2016-05-16 10:58:34 +08:00
|
|
|
<div style={{ height: 220 }}>
|
|
|
|
内容区域
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-12-23 17:58:37 +08:00
|
|
|
<div className="layout-footer">
|
2016-05-16 10:58:34 +08:00
|
|
|
Ant Design 版权所有 © 2015 由蚂蚁金服体验技术部支持
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2016-05-16 14:35:24 +08:00
|
|
|
|
2016-05-16 10:58:34 +08:00
|
|
|
ReactDOM.render(<BrowserDemo><AsideCollapse /></BrowserDemo>, mountNode);
|
|
|
|
````
|
|
|
|
|
|
|
|
````css
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside {
|
2016-05-16 10:58:34 +08:00
|
|
|
position: relative;
|
|
|
|
min-height: 100%;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-logo {
|
2016-05-16 10:58:34 +08:00
|
|
|
height: 32px;
|
|
|
|
background: #333;
|
2016-12-23 17:58:37 +08:00
|
|
|
border-radius: 4px;
|
|
|
|
margin: 16px 24px;
|
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-logo {
|
2016-05-16 10:58:34 +08:00
|
|
|
width: 32px;
|
|
|
|
margin: 16px;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-sider {
|
2016-05-16 10:58:34 +08:00
|
|
|
width: 224px;
|
|
|
|
background: #404040;
|
|
|
|
position: absolute;
|
|
|
|
overflow: visible;
|
|
|
|
padding-bottom: 24px;
|
|
|
|
height: 100%;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-sider {
|
2016-05-16 10:58:34 +08:00
|
|
|
width: 64px;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-sider > .menu {
|
2016-05-16 10:58:34 +08:00
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-sider > .menu > .menu-item {
|
2016-05-16 10:58:34 +08:00
|
|
|
margin: 16px 0;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-sider > .menu > .menu-item .nav-text {
|
2016-05-20 14:19:09 +08:00
|
|
|
vertical-align: baseline;
|
2016-05-18 11:43:40 +08:00
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-sider > .menu > .menu-item > .anticon {
|
2016-05-18 11:43:40 +08:00
|
|
|
transition: font-size .3s;
|
2016-05-16 14:35:24 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-sider > .menu > .menu-item {
|
2016-05-16 10:58:34 +08:00
|
|
|
transition: all 0s ease;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-sider > .menu > .menu-item > .anticon {
|
2016-05-16 14:35:24 +08:00
|
|
|
font-size: 16px;
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-sider > .menu > .menu-item .nav-text {
|
2016-05-16 10:58:34 +08:00
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-sider > .menu > .menu-item:hover {
|
2016-05-16 10:58:34 +08:00
|
|
|
background: #2db7f5;
|
|
|
|
color: #fff;
|
|
|
|
transition: all 0s ease;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-sider > .menu > .menu-item:hover .nav-text {
|
2016-05-16 10:58:34 +08:00
|
|
|
display: inline-block;
|
2016-05-16 14:35:24 +08:00
|
|
|
vertical-align: top;
|
2016-05-16 10:58:34 +08:00
|
|
|
background: #2db7f5;
|
|
|
|
color: #fff;
|
|
|
|
padding-right: 16px;
|
|
|
|
border-radius: 0 5px 5px 0;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:35:24 +08:00
|
|
|
/* 实际使用中需要改成 position: fixed */
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .aside-action {
|
2016-05-16 10:58:34 +08:00
|
|
|
height: 42px;
|
|
|
|
width: 224px;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
background: #656565;
|
|
|
|
color: #fff;
|
|
|
|
text-align: center;
|
|
|
|
line-height: 42px;
|
|
|
|
cursor: pointer;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .aside-action {
|
2016-05-16 10:58:34 +08:00
|
|
|
width: 64px;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-header {
|
2016-05-16 10:58:34 +08:00
|
|
|
background: #fff;
|
|
|
|
height: 64px;
|
|
|
|
border-bottom: 1px solid #e9e9e9;
|
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-main {
|
2016-05-16 10:58:34 +08:00
|
|
|
margin-left: 224px;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside-collapse .layout-main {
|
2016-05-16 10:58:34 +08:00
|
|
|
margin-left: 64px;
|
2016-12-23 17:58:37 +08:00
|
|
|
transition: all .3s;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-container {
|
|
|
|
margin: 12px 16px 24px;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-content {
|
2016-05-16 10:58:34 +08:00
|
|
|
background: #fff;
|
|
|
|
padding: 24px;
|
2016-12-23 17:58:37 +08:00
|
|
|
margin-top: 12px;
|
|
|
|
border-radius: 4px;
|
2016-05-16 10:58:34 +08:00
|
|
|
}
|
|
|
|
|
2016-12-23 17:58:37 +08:00
|
|
|
.layout-aside .layout-footer {
|
2016-05-16 10:58:34 +08:00
|
|
|
height: 64px;
|
|
|
|
line-height: 64px;
|
|
|
|
text-align: center;
|
|
|
|
font-size: 12px;
|
|
|
|
color: #999;
|
|
|
|
background: #fff;
|
|
|
|
border-top: 1px solid #e9e9e9;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
````
|