Scrolling to an element on the same page - screen size issues

Hi all, I'm creating a navbar that scrolls to items on the same page, i.e. 'contact' will scroll to the #contact section, 'about' to #about etc. I haven't started yet but I remember this being messy, having to implement scroll-margin-top/similar js solutions when the snap was off slightly - this would get even messier when having to accommodate for different screensizes. I'm wondering the best way to go about this? perhaps there's a package? Thanks for your help!
2 Replies
clevermissfox
clevermissfox2mo ago
Css scroll-margin and scroll-padding. I’m not sure of your layout or why different screen sizes would affect it. Scrolling to 1rem above of the section will be 1rem no matter the screen size of the section
FROSTYTIPS
FROSTYTIPSOP2mo ago
Thanks a lot @clevermissfox , for some reason I remembered this being a lot worse than it was!
Want results from more Discord servers?
Add your server