ant-design/components/affix/demo/target.md
2016-10-30 15:11:22 +08:00

1.1 KiB

order title
2
zh-CN en-US
滚动容器 Container to scroll.

zh-CN

target 设置 Affix 需要监听其滚动事件的元素,默认为 window

en-US

Set a target for 'Affix', which is listen to scroll event of target element (default is window).

import { Affix, Button } from 'antd';

const Demo = () => {
  return (
    <div className="view-port">
      <div id="scrollable-container">
        <div className="background">
          <br />
          <br />
          <br />
          <Affix target={() => document.getElementById('scrollable-container')} offsetTop={20}>
            <Button type="primary">Fixed at the top of container</Button>
          </Affix>
        </div>
      </div>
    </div>
  );
};

ReactDOM.render(<Demo />, mountNode);