2017-03-05 20:02:53 +08:00
|
|
|
---
|
|
|
|
order: 6
|
2017-03-18 14:52:23 +08:00
|
|
|
iframe: 360
|
2017-03-05 20:02:53 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 固定头部
|
|
|
|
en-US: Fixed Header
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
一般用于固定顶部导航,方便页面切换。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Fixed Header is generally used to fix the top navigation to facilitate page switching.
|
|
|
|
|
2022-03-18 15:20:35 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Breadcrumb, Layout, Menu } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React from 'react';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-03-05 20:02:53 +08:00
|
|
|
const { Header, Content, Footer } = Layout;
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2017-03-05 20:02:53 +08:00
|
|
|
<Layout>
|
2022-11-14 11:16:34 +08:00
|
|
|
<Header style={{ position: 'sticky', top: 0, zIndex: 1, width: '100%' }}>
|
2017-03-05 20:02:53 +08:00
|
|
|
<div className="logo" />
|
2022-03-18 15:20:35 +08:00
|
|
|
<Menu
|
|
|
|
theme="dark"
|
|
|
|
mode="horizontal"
|
|
|
|
defaultSelectedKeys={['2']}
|
|
|
|
items={new Array(3).fill(null).map((_, index) => ({
|
|
|
|
key: String(index + 1),
|
|
|
|
label: `nav ${index + 1}`,
|
|
|
|
}))}
|
|
|
|
/>
|
2017-03-05 20:02:53 +08:00
|
|
|
</Header>
|
2022-11-14 11:16:34 +08:00
|
|
|
<Content className="site-layout" style={{ padding: '0 50px' }}>
|
2017-10-16 20:39:53 +08:00
|
|
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
2017-03-05 20:02:53 +08:00
|
|
|
<Breadcrumb.Item>Home</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>List</Breadcrumb.Item>
|
|
|
|
<Breadcrumb.Item>App</Breadcrumb.Item>
|
|
|
|
</Breadcrumb>
|
2020-01-02 17:54:11 +08:00
|
|
|
<div className="site-layout-background" style={{ padding: 24, minHeight: 380 }}>
|
|
|
|
Content
|
|
|
|
</div>
|
2017-03-05 20:02:53 +08:00
|
|
|
</Content>
|
2019-05-07 14:57:32 +08:00
|
|
|
<Footer style={{ textAlign: 'center' }}>Ant Design ©2018 Created by Ant UED</Footer>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Layout>
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2017-03-05 20:02:53 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```css
|
2017-03-05 20:02:53 +08:00
|
|
|
#components-layout-demo-fixed .logo {
|
2021-01-30 19:39:02 +08:00
|
|
|
float: left;
|
2017-03-05 20:02:53 +08:00
|
|
|
width: 120px;
|
|
|
|
height: 31px;
|
|
|
|
margin: 16px 24px 16px 0;
|
2021-01-30 19:39:02 +08:00
|
|
|
background: rgba(255, 255, 255, 0.2);
|
2017-03-05 20:02:53 +08:00
|
|
|
}
|
2020-01-02 17:54:11 +08:00
|
|
|
.site-layout .site-layout-background {
|
|
|
|
background: #fff;
|
|
|
|
}
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2020-01-02 17:54:11 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .site-layout .site-layout-background {
|
|
|
|
background: #141414;
|
|
|
|
}
|
|
|
|
</style>
|