Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can the sticky header follow the horizontal scrolling? #94

Open
mrdulin opened this issue Jan 22, 2024 · 0 comments
Open

Can the sticky header follow the horizontal scrolling? #94

mrdulin opened this issue Jan 22, 2024 · 0 comments

Comments

@mrdulin
Copy link

mrdulin commented Jan 22, 2024

import './style.css';
import Sticky from 'react-sticky-el';

export const App = () => {
  const panels = [{ id: 1 }, { id: 2 }, { id: 3 }];

  return (
    <div className="wrapper">
      <div style={{ display: 'flex', marginTop: 40 }}>
        {panels.map((p) => (
          <div key={p.id} className="panel">
            <Sticky scrollElement=".wrapper">
              <div className="panel-header">header {p.id}</div>
            </Sticky>
            <div className="panel-content">content {p.id}</div>
          </div>
        ))}
      </div>
    </div>
  );
};

style.scss:

.wrapper {
  position: relative;
  height: 300px;
  width: 600px;
  overflow: auto;
  border: 1px solid #ddd;
}

.panel-header {
  background-color: red;
}

.panel-content {
  background-color: yellow;
  height: 600px;
}

.panel {
  width: 200px;
  margin: 0 10px;
  flex-shrink: 0;
}

image

The sticky header does not follow the horizontal scrolling.

stackblitz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant