Fixed Element
Make an element fix on scrolling:
import { ScrollContainer, FixedElement } from 'react-nice-scroll';
import 'react-nice-scroll/dist/styles.css';
const Index = () => {
return (
<ScrollContainer>
<section style={{ height: '300vh' }}>
<FixedElement left={10} top={10}>
<span>Fixed Elemet</span>
</FixedElement>
<h1>Hello World!</h1>
</section>
</ScrollContainer>
);
};
export default Index;
Demo
Check demo.
FixedElement Props
Props | Value Type | Default Value |
---|---|---|
top | number | 0 |
right | number | undefined | undefined |
left | number | undefined | undefined |