Skip to content

Use CSS instead of JS for floating docs banner #1988

Open
@adamzap

Description

@adamzap

When I refactored the JavaScript for the floating docs banner in #1972, I suggested using a CSS-only solution. I tried unsuccessfully in #1799, but I hope position: sticky could still work somehow.

Another approach would be to use position: fixed, but we would have to make the content fixed-height. This would be difficult given the amount of text that is currently in the banner element:

Image Image Image Image

The current JavaScript approach feels a bit complex to me and can lead to some odd scroll behavior.


I think this (S)CSS should work if we can make the element fixed-height:

html:has(#dev-warning, #outdated-warning) {
    scroll-padding-top: 38px;
}

body:has(#dev-warning, #outdated-warning) {
    margin-top: 38px;
}

#dev-warning,
#outdated-warning {
    height: 38px;
    position: fixed;
}

I'd be happy to implement a solution if there is a way forward here.

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