position sticky not working react code example
Example 1: React sticky header
npm install react-sticky
import React from 'react';
import { StickyContainer, Sticky } from 'react-sticky';
class App extends React.Component {
render() {
return (
<StickyContainer>
{}
<Sticky>
{({
style,
isSticky,
wasSticky,
distanceFromTop,
distanceFromBottom,
calculatedHeight
}) => (
<header style={style}>
{}
</header>
)}
</Sticky>
{}
</StickyContainer>
);
},
};
Example 2: sticky header not working chrome
thead tr:nth-child(1) th{
background: white;
position: sticky;
top: 0;
z-index: 10;
}