Skip to content

Feature Request: Top viewport offset for when margin-top = 0 #4

@tbredin

Description

@tbredin

Using margin-top seems like it isn't the ideal way to specify where position: fixed starts getting applied, since this requires styling your layout with the sidebar initially pushed down the page if you want it to be spaced from the viewport edge when scrolling. I feel that forcing margin-top is quite restrictive and isn't very flexible (eg: My sidebar is under a header which provides the top spacing, but the sidebar itself NEEDS margin-top: 0; to line up with it's associated main content).

A possible solution would be to use the "top" value instead of "margin-top" since this usually wouldn't affect the initial element positioning when position: static is applied (afaik).

Alternatively it could be nice to have an optional parameter for "additional top viewport offset" when the function is called, which would keep the sidebar this far from the viewport edge even if the top margin is initially set to 0.

I imagine the same could be true for the bottom values, however isn't immediately apparent since it usually won't affect the initial styling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions