mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 23:35:38 +08:00
30 lines
656 B
TypeScript
30 lines
656 B
TypeScript
import React from 'react';
|
|
import { Affix, Button } from 'antd';
|
|
|
|
const containerStyle: React.CSSProperties = {
|
|
width: '100%',
|
|
height: 100,
|
|
overflow: 'auto',
|
|
border: '1px solid #40a9ff',
|
|
};
|
|
|
|
const style: React.CSSProperties = {
|
|
width: '100%',
|
|
height: 1000,
|
|
};
|
|
|
|
const App: React.FC = () => {
|
|
const [container, setContainer] = React.useState<HTMLDivElement | null>(null);
|
|
return (
|
|
<div style={containerStyle} ref={setContainer}>
|
|
<div style={style}>
|
|
<Affix target={() => container}>
|
|
<Button type="primary">Fixed at the top of container</Button>
|
|
</Affix>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default App;
|