Layout 布局

Layout 布局

协助进行页面级整体布局。

设计规则

尺寸

一级导航项偏左靠近 logo 放置,辅助菜单偏右放置。

  • 顶部导航(大部分系统):一级导航高度 64px,二级导航 48px

交互

  • 一级导航和末级的导航需要在可视化的层面被强调出来;

视觉

导航样式上需要根据信息层级合理的选择样式:

  • 大色块强调 建议用于底色为深色系时,当前页面父级的导航项。

组件概述

  • Layout:布局容器,其下可嵌套 Header、Sider、Content、FooterLayout 本身,可以放在任何父容器中。

注意:采用 flex 布局实现,请注意浏览器兼容性问题。

代码示例

<template> <div class="layout"> <Layout> <Header>Header</Header> <Content>Content</Content> <Footer>Footer</Footer> </Layout> <Layout> <Header>Header</Header> <Layout> <Sider hide-trigger>Sider</Sider> <Content>Content</Content> </Layout> <Footer>Footer</Footer> </Layout> <Layout> <Header>Header</Header> <Layout> <Content>Content</Content> <Sider hide-trigger>Sider</Sider> </Layout> <Footer>Footer</Footer> </Layout> <Layout> <Sider hide-trigger>Sider</Sider> <Layout> <Header>Header</Header> <Content>Content</Content> <Footer>Footer</Footer> </Layout> </Layout> </div> </template> <script> export default { } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-logo{ width: 100px; height: 30px; background: #5b6270; border-radius: 3px; float: left; position: relative; top: 15px; left: 20px; } .layout-nav{ width: 420px; margin: 0 auto; margin-right: 20px; } .layout-footer-center{ text-align: center; } </style> <template> <div class="layout"> <Layout> <Header> <Menu mode="horizontal" theme="dark" active-name="1"> <div class="layout-logo"></div> <div class="layout-nav"> <MenuItem name="1"> <Icon type="ios-navigate"></Icon> Item 1 </MenuItem> <MenuItem name="2"> <Icon type="ios-keypad"></Icon> Item 2 </MenuItem> <MenuItem name="3"> <Icon type="ios-analytics"></Icon> Item 3 </MenuItem> <MenuItem name="4"> <Icon type="ios-paper"></Icon> Item 4 </MenuItem> </div> </Menu> </Header> <Content :style="{padding: '0 50px'}"> <Breadcrumb :style="{margin: '20px 0'}"> <BreadcrumbItem>Home</BreadcrumbItem> <BreadcrumbItem>Components</BreadcrumbItem> <BreadcrumbItem>Layout</BreadcrumbItem> </Breadcrumb> <Card> <div style="min-height: 200px;"> Content </div> </Card> </Content> <Footer class="layout-footer-center">2011-2016 &copy; TalkingData</Footer> </Layout> </div> </template> <script> export default { } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-logo{ width: 100px; height: 30px; background: #5b6270; border-radius: 3px; float: left; position: relative; top: 15px; left: 20px; } .layout-nav{ width: 420px; margin: 0 auto; margin-right: 20px; } </style> <template> <div class="layout"> <Layout> <Header> <Menu mode="horizontal" theme="dark" active-name="1"> <div class="layout-logo"></div> <div class="layout-nav"> <MenuItem name="1"> <Icon type="ios-navigate"></Icon> Item 1 </MenuItem> <MenuItem name="2"> <Icon type="ios-keypad"></Icon> Item 2 </MenuItem> <MenuItem name="3"> <Icon type="ios-analytics"></Icon> Item 3 </MenuItem> <MenuItem name="4"> <Icon type="ios-paper"></Icon> Item 4 </MenuItem> </div> </Menu> </Header> <Layout> <Sider hide-trigger :style="{background: '#fff'}"> <Menu active-name="1-2" theme="light" width="auto" :open-names="['1']"> <Submenu name="1"> <template slot="title"> <Icon type="ios-navigate"></Icon> Item 1 </template> <MenuItem name="1-1">Option 1</MenuItem> <MenuItem name="1-2">Option 2</MenuItem> <MenuItem name="1-3">Option 3</MenuItem> </Submenu> <Submenu name="2"> <template slot="title"> <Icon type="ios-keypad"></Icon> Item 2 </template> <MenuItem name="2-1">Option 1</MenuItem> <MenuItem name="2-2">Option 2</MenuItem> </Submenu> <Submenu name="3"> <template slot="title"> <Icon type="ios-analytics"></Icon> Item 3 </template> <MenuItem name="3-1">Option 1</MenuItem> <MenuItem name="3-2">Option 2</MenuItem> </Submenu> </Menu> </Sider> <Layout :style="{padding: '0 24px 24px'}"> <Breadcrumb :style="{margin: '24px 0'}"> <BreadcrumbItem>Home</BreadcrumbItem> <BreadcrumbItem>Components</BreadcrumbItem> <BreadcrumbItem>Layout</BreadcrumbItem> </Breadcrumb> <Content :style="{padding: '24px', minHeight: '280px', background: '#fff'}"> Content </Content> </Layout> </Layout> </Layout> </div> </template> <script> export default { } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-logo{ width: 100px; height: 30px; background: #5b6270; border-radius: 3px; float: left; position: relative; top: 15px; left: 20px; } .layout-nav{ width: 420px; margin: 0 auto; margin-right: 20px; } .layout-footer-center{ text-align: center; } </style> <template> <div class="layout"> <Layout> <Header> <Menu mode="horizontal" theme="dark" active-name="1"> <div class="layout-logo"></div> <div class="layout-nav"> <MenuItem name="1"> <Icon type="ios-navigate"></Icon> Item 1 </MenuItem> <MenuItem name="2"> <Icon type="ios-keypad"></Icon> Item 2 </MenuItem> <MenuItem name="3"> <Icon type="ios-analytics"></Icon> Item 3 </MenuItem> <MenuItem name="4"> <Icon type="ios-paper"></Icon> Item 4 </MenuItem> </div> </Menu> </Header> <Layout :style="{padding: '0 50px'}"> <Breadcrumb :style="{margin: '16px 0'}"> <BreadcrumbItem>Home</BreadcrumbItem> <BreadcrumbItem>Components</BreadcrumbItem> <BreadcrumbItem>Layout</BreadcrumbItem> </Breadcrumb> <Content :style="{padding: '24px 0', minHeight: '280px', background: '#fff'}"> <Layout> <Sider hide-trigger :style="{background: '#fff'}"> <Menu active-name="1-2" theme="light" width="auto" :open-names="['1']"> <Submenu name="1"> <template slot="title"> <Icon type="ios-navigate"></Icon> Item 1 </template> <MenuItem name="1-1">Option 1</MenuItem> <MenuItem name="1-2">Option 2</MenuItem> <MenuItem name="1-3">Option 3</MenuItem> </Submenu> <Submenu name="2"> <template slot="title"> <Icon type="ios-keypad"></Icon> Item 2 </template> <MenuItem name="2-1">Option 1</MenuItem> <MenuItem name="2-2">Option 2</MenuItem> </Submenu> <Submenu name="3"> <template slot="title"> <Icon type="ios-analytics"></Icon> Item 3 </template> <MenuItem name="3-1">Option 1</MenuItem> <MenuItem name="3-2">Option 2</MenuItem> </Submenu> </Menu> </Sider> <Content :style="{padding: '24px', minHeight: '280px', background: '#fff'}"> Content </Content> </Layout> </Content> </Layout> <Footer class="layout-footer-center">2011-2016 &copy; TalkingData</Footer> </Layout> </div> </div> </template> <script> export default { } </script>

<style scoped> .layout-con{ height: 100%; width: 100%; } .menu-item span{ display: inline-block; overflow: hidden; width: 69px; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; transition: width .2s ease .2s; } .menu-item i{ transform: translateX(0px transition: font-size .2s ease, transform .2s ease; vertical-align: middle; font-size: 16px; } .collapsed-menu span{ width: 0px; transition: width .2s ease; } .collapsed-menu i{ transform: translateX(5px transition: font-size .2s ease .2s, transform .2s ease .2s; vertical-align: middle; font-size: 22px; } </style> <template> <div class="layout"> <Layout :style="{minHeight: '100vh'}"> <Sider collapsible :collapsed-width="78" v-model="isCollapsed"> <Menu active-name="1-2" theme="dark" width="auto" :class="menuitemClasses"> <MenuItem name="1-1"> <Icon type="ios-navigate"></Icon> <span>Option 1</span> </MenuItem> <MenuItem name="1-2"> <Icon type="search"></Icon> <span>Option 2</span> </MenuItem> <MenuItem name="1-3"> <Icon type="settings"></Icon> <span>Option 3</span> </MenuItem> </Menu> </Sider> <Layout> <Header :style="{background: '#fff', boxShadow: '0 2px 3px 2px rgba(0,0,0,.1)'}"></Header> <Content :style="{padding: '0 16px 16px'}"> <Breadcrumb :style="{margin: '16px 0'}"> <BreadcrumbItem>Home</BreadcrumbItem> <BreadcrumbItem>Components</BreadcrumbItem> <BreadcrumbItem>Layout</BreadcrumbItem> </Breadcrumb> <Card> <div style="height: 600px">Content</div> </Card> </Content> </Layout> </Layout> </div> </template> <script> export default { data () { return { isCollapsed: false }; }, computed: { menuitemClasses: function () { return [ 'menu-item', this.isCollapsed ? 'collapsed-menu' : '' ] } } } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-header-bar{ background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.1 } .layout-logo-left{ width: 90%; height: 30px; background: #5b6270; border-radius: 3px; margin: 15px auto; } .menu-icon{ transition: all .3s; } .rotate-icon{ transform: rotate(-90deg } .menu-item span{ display: inline-block; overflow: hidden; width: 69px; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; transition: width .2s ease .2s; } .menu-item i{ transform: translateX(0px transition: font-size .2s ease, transform .2s ease; vertical-align: middle; font-size: 16px; } .collapsed-menu span{ width: 0px; transition: width .2s ease; } .collapsed-menu i{ transform: translateX(5px transition: font-size .2s ease .2s, transform .2s ease .2s; vertical-align: middle; font-size: 22px; } </style> <template> <div class="layout"> <Layout> <Sider ref="side1" hide-trigger collapsible :collapsed-width="78" v-model="isCollapsed"> <Menu active-name="1-2" theme="dark" width="auto" :class="menuitemClasses"> <MenuItem name="1-1"> <Icon type="ios-navigate"></Icon> <span>Option 1</span> </MenuItem> <MenuItem name="1-2"> <Icon type="ios-search"></Icon> <span>Option 2</span> </MenuItem> <MenuItem name="1-3"> <Icon type="ios-settings"></Icon> <span>Option 3</span> </MenuItem> </Menu> </Sider> <Layout> <Header :style="{padding: 0}" class="layout-header-bar"> <Icon @click.native="collapsedSider" :class="rotateIcon" :style="{margin: '0 20px'}" type="md-menu" size="24"></Icon> </Header> <Content :style="{margin: '20px', background: '#fff', minHeight: '260px'}"> Content </Content> </Layout> </Layout> </div> </template> <script> export default { data () { return { isCollapsed: false } }, computed: { rotateIcon () { return [ 'menu-icon', this.isCollapsed ? 'rotate-icon' : '' ]; }, menuitemClasses () { return [ 'menu-item', this.isCollapsed ? 'collapsed-menu' : '' ] } }, methods: { collapsedSider () { this.$refs.side1.toggleCollapse( } } } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-header-bar{ background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.1 } .menu-item span{ display: inline-block; overflow: hidden; width: 69px; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; transition: width .2s ease .2s; } .menu-item i{ transform: translateX(0px transition: font-size .2s ease, transform .2s ease; vertical-align: middle; font-size: 16px; } .collapsed-menu span{ width: 0px; transition: width .2s ease; } .collapsed-menu i{ transform: translateX(5px transition: font-size .2s ease .2s, transform .2s ease .2s; vertical-align: middle; font-size: 22px; } </style> <template> <div class="layout"> <Layout> <Sider breakpoint="md" collapsible :collapsed-width="78" v-model="isCollapsed"> <Menu active-name="1-2" theme="dark" width="auto" :class="menuitemClasses"> <MenuItem name="1-1"> <Icon type="ios-navigate"></Icon> <span>Option 1</span> </MenuItem> <MenuItem name="1-2"> <Icon type="ios-search"></Icon> <span>Option 2</span> </MenuItem> <MenuItem name="1-3"> <Icon type="ios-settings"></Icon> <span>Option 3</span> </MenuItem> </Menu> <div slot="trigger"></div> </Sider> <Layout> <Header class="layout-header-bar"></Header> <Content :style="{margin: '20px', background: '#fff', minHeight: '220px'}"> Content </Content> </Layout> </Layout> </div> </template> <script> export default { data () { return { isCollapsed: false }; }, computed: { menuitemClasses: function () { return [ 'menu-item', this.isCollapsed ? 'collapsed-menu' : '' ] } } } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-logo{ width: 100px; height: 30px; background: #5b6270; border-radius: 3px; float: left; position: relative; top: 15px; left: 20px; } .layout-nav{ width: 420px; margin: 0 auto; margin-right: 20px; } .layout-footer-center{ text-align: center; } </style> <template> <div class="layout"> <Layout> <Header :style="{position: 'fixed', width: '100%'}"> <Menu mode="horizontal" theme="dark" active-name="1"> <div class="layout-logo"></div> <div class="layout-nav"> <MenuItem name="1"> <Icon type="ios-navigate"></Icon> Item 1 </MenuItem> <MenuItem name="2"> <Icon type="ios-keypad"></Icon> Item 2 </MenuItem> <MenuItem name="3"> <Icon type="ios-analytics"></Icon> Item 3 </MenuItem> <MenuItem name="4"> <Icon type="ios-paper"></Icon> Item 4 </MenuItem> </div> </Menu> </Header> <Content :style="{margin: '88px 20px 0', background: '#fff', minHeight: '500px'}"> Content </Content> <Footer class="layout-footer-center">2011-2016 &copy; TalkingData</Footer> </Layout> </div> </template> <script> export default { } </script>

<style scoped> .layout{ border: 1px solid #d7dde4; background: #f5f7f9; position: relative; border-radius: 4px; overflow: hidden; } .layout-header-bar{ background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.1 } </style> <template> <div class="layout"> <Sider :style="{position: 'fixed', height: '100vh', left: 0, overflow: 'auto'}"> <Menu active-name="1-2" theme="dark" width="auto" :open-names="['1']"> <Submenu name="1"> <template slot="title"> <Icon type="ios-navigate"></Icon> Item 1 </template> <MenuItem name="1-1">Option 1</MenuItem> <MenuItem name="1-2">Option 2</MenuItem> <MenuItem name="1-3">Option 3</MenuItem> </Submenu> <Submenu name="2"> <template slot="title"> <Icon type="ios-keypad"></Icon> Item 2 </template> <MenuItem name="2-1">Option 1</MenuItem> <MenuItem name="2-2">Option 2</MenuItem> </Submenu> <Submenu name="3"> <template slot="title"> <Icon type="ios-analytics"></Icon> Item 3 </template> <MenuItem name="3-1">Option 1</MenuItem> <MenuItem name="3-2">Option 2</MenuItem> </Submenu> </Menu> </Sider> <Layout :style="{marginLeft: '200px'}"> <Header :style="{background: '#fff', boxShadow: '0 2px 3px 2px rgba(0,0,0,.1)'}"></Header> <Content :style="{padding: '0 16px 16px'}"> <Breadcrumb :style="{margin: '16px 0'}"> <BreadcrumbItem>Home</BreadcrumbItem> <BreadcrumbItem>Components</BreadcrumbItem> <BreadcrumbItem>Layout</BreadcrumbItem> </Breadcrumb> <Card> <div style="height: 600px">Content</div> </Card> </Content> </Layout> </div> </template> <script> export default { } </script>