2016-03-31 09:40:55 +08:00
---
order: 0
2017-01-23 11:08:46 +08:00
title:
zh-CN: 顶部导航
en-US: Top
2016-03-31 09:40:55 +08:00
---
2017-01-23 11:08:46 +08:00
## zh-CN
2015-11-09 19:40:35 +08:00
2015-11-09 18:05:23 +08:00
一二级导航都在顶部。
2015-11-14 21:08:43 +08:00
顶部导航在页面布局上采用的是上下的结构, 一般主导航放置于页面的顶端, 从左自右依次为: logo、一级导航项、辅助菜单( 用户、设置、通知等) 。通常将内容放在固定尺寸( 例如: 1200px) 内, 整个页面排版稳定, 不受用户终端显示器影响; 上下级的结构符合用户上下浏览的习惯, 也是较为经典的网站导航模式。页面上下切分的方式提高了主工作区域的信息展示效率, 但在纵向空间上会有一些牺牲。此外, 由于导航栏水平空间的限制, 不适合那些一级导航项很多的信息结构。
2015-11-09 21:00:30 +08:00
> `<BrowserDemo />` 做演示用,无须复制。
2017-01-23 11:08:46 +08:00
## en-US
2017-01-25 21:10:42 +08:00
The first and second level nav are both on the top.
2017-01-23 11:08:46 +08:00
2017-01-25 21:10:42 +08:00
A top-bottom structure of page layouts is used for top navigation. Generally, the mainnav is placed at the top of the page, and includes the logo, the first level navigation, and the secondary menu (users, settings, notifications) from left to right in it.
We always put contents in a fixed size navigation (eg: `1200px` ), the layout of the whole page is stable, it's not affected by viewing area.
Top-bottom structure is conform with the top-bottom viewing habit, it's a classical navigation pattern of websites. This pattern demonstrates efficiency in the main workarea, while using some vertical space. And because the horizontal space of the navigation is limited, this pattern is not suitable for cases when the first level navigation contains many elements or links.
2017-01-23 11:08:46 +08:00
> `<BrowserDemo />` This is for demo, don't need to copy.
2017-01-19 15:19:03 +08:00
````__react
2015-11-09 19:40:35 +08:00
import { Menu, Breadcrumb } from 'antd';
2016-05-27 11:48:08 +08:00
import BrowserDemo from 'site/theme/template/BrowserDemo';
2015-11-09 19:40:35 +08:00
2015-11-09 18:05:23 +08:00
ReactDOM.render(
2015-11-09 21:00:30 +08:00
< BrowserDemo >
2016-12-23 17:58:37 +08:00
< div className = "layout-top" >
< div className = "layout-header" >
< div className = "layout-wrapper" >
< div className = "layout-logo" > < / div >
2015-11-14 20:41:10 +08:00
< Menu theme = "dark" mode = "horizontal"
defaultSelectedKeys={['2']} style={{lineHeight: '64px'}}>
2017-01-23 11:08:46 +08:00
< Menu.Item key = "1" > Navigation 1< / Menu.Item >
< Menu.Item key = "2" > Navigation 2< / Menu.Item >
< Menu.Item key = "3" > Navigation 3< / Menu.Item >
2015-11-14 20:41:10 +08:00
< / Menu >
< / div >
< / div >
2016-12-23 17:58:37 +08:00
< div className = "layout-subheader" >
< div className = "layout-wrapper" >
2015-11-14 20:41:10 +08:00
< Menu mode = "horizontal"
defaultSelectedKeys={['1']} style={{marginLeft: 124}}>
2017-02-09 16:22:03 +08:00
< Menu.Item key = "1" > Second nav< / Menu.Item >
< Menu.Item key = "2" > Second nav< / Menu.Item >
< Menu.Item key = "3" > Second nav< / Menu.Item >
2015-11-14 20:41:10 +08:00
< / Menu >
< / div >
< / div >
2016-12-23 17:58:37 +08:00
< div className = "layout-wrapper" >
< Breadcrumb >
2017-01-23 11:08:46 +08:00
< Breadcrumb.Item > Home< / Breadcrumb.Item >
< Breadcrumb.Item > App list< / Breadcrumb.Item >
< Breadcrumb.Item > Any app< / Breadcrumb.Item >
2016-12-23 17:58:37 +08:00
< / Breadcrumb >
< div className = "layout-container" >
2015-11-19 22:00:54 +08:00
< div style = {{ height: 210 } } > < / div >
2015-11-09 21:00:30 +08:00
< / div >
2015-11-09 19:40:35 +08:00
< / div >
2016-12-23 17:58:37 +08:00
< div className = "layout-footer" >
2017-01-23 11:08:46 +08:00
Ant Design all rights reserved © 2015 Created by Ant UED
2015-11-14 21:08:43 +08:00
< / div >
2015-11-09 19:40:35 +08:00
< / div >
2015-11-09 21:00:30 +08:00
< / BrowserDemo >
2016-01-08 18:10:58 +08:00
, mountNode);
2015-11-09 18:05:23 +08:00
````
````css
2016-12-23 17:58:37 +08:00
.layout-top {
2015-11-09 21:00:30 +08:00
height: 100%;
2015-11-09 19:40:35 +08:00
}
2016-12-23 17:58:37 +08:00
.layout-top .layout-wrapper {
2015-11-14 20:41:10 +08:00
padding: 0 50px;
}
2016-12-23 17:58:37 +08:00
.layout-top .layout-header {
2015-11-14 20:41:10 +08:00
background: #404040 ;
2015-11-09 19:40:35 +08:00
height: 64px;
}
2016-12-23 17:58:37 +08:00
.layout-top .layout-logo {
2015-11-14 20:41:10 +08:00
width: 120px;
height: 32px;
background: #333 ;
2016-12-23 17:58:37 +08:00
border-radius: 4px;
margin: 16px 24px 16px 0;
2015-11-14 20:41:10 +08:00
float: left;
}
2016-12-23 17:58:37 +08:00
.layout-top .layout-subheader {
2015-11-09 19:40:35 +08:00
height: 48px;
2015-11-14 21:08:43 +08:00
border-bottom: 1px solid #e9e9e9 ;
2015-11-09 19:40:35 +08:00
background: #fff ;
2016-12-23 17:58:37 +08:00
margin-bottom: 12px;
2015-11-09 19:40:35 +08:00
}
2016-12-23 17:58:37 +08:00
.layout-top .layout-container {
2015-11-09 19:40:35 +08:00
background: #fff ;
2016-12-23 17:58:37 +08:00
margin: 12px 0 0;
2015-11-14 20:41:10 +08:00
position: relative;
padding-top: 24px;
overflow: hidden;
2016-12-23 17:58:37 +08:00
border-radius: 4px;
2015-11-09 18:17:37 +08:00
}
2015-11-14 21:08:43 +08:00
2016-12-23 17:58:37 +08:00
.layout-top .layout-footer {
2016-01-14 11:08:57 +08:00
height: 64px;
2015-11-14 21:12:02 +08:00
line-height: 64px;
2015-11-14 21:08:43 +08:00
text-align: center;
font-size: 12px;
color: #999 ;
}
2015-11-09 18:17:37 +08:00
````