Skip to content

changing <body> margin to padding break margin-collapsing #145

@zunsthy

Description

@zunsthy

if no style for body, default margin of body style will be reset and the same size padding will be set due to [data-scroll-locked] attr.

the first node, such as P, H1, H2, ..., margin-top and body's margin-top can collapse. the component, that replace margin-top to padding-top, break vertical margin-collapsing behavior.

example:

const App = () => {
  const [v, sv] = useState(false);
  const toggle = () => sv(v => !v);
  return (
    <p>
      <button onClick={toggle}>Button</button>
      <span style={{ position: 'relative' }}>
        {v ? (
          <div style={{ position: 'absolute' }}>
            <RemoveScroll>
              <span>Pop</span>
            </RemoveScroll>
          </div>
        ) : null}
      </span>
    </p>
  );
}

pop hide:

Image

pop visiable:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions