Skip to content

Use CSS instead of JS for floating docs banner #1988

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

Open
adamzap opened this issue Mar 14, 2025 · 3 comments · May be fixed by #2075
Open

Use CSS instead of JS for floating docs banner #1988

adamzap opened this issue Mar 14, 2025 · 3 comments · May be fixed by #2075

Comments

@adamzap
Copy link
Member

adamzap commented Mar 14, 2025

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.

@arpan8925
Copy link
Contributor

Where this floating error visually can be seen? in which page ?

@adamzap
Copy link
Member Author

adamzap commented Mar 28, 2025

arpan8925 added a commit to arpan8925/djangoproject.com that referenced this issue May 14, 2025
@arpan8925
Copy link
Contributor

@adamzap I tried doing a PR with that specific commit, but it just took all my commits, don't know how, need help in that case, also check the last commit, it may fix it

arpan8925 added a commit to arpan8925/djangoproject.com that referenced this issue May 17, 2025
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

Successfully merging a pull request may close this issue.

2 participants