Archived topic
Floating sidebar
7 replies · Started by Maarten on February 14, 2022
The question has probably been answered a million times already, but none of the previous answers seem to work on my site.
I have a sidebar with two widgets. How can I make this sidebar sticky, so the visitor will still see the widgets if they scroll down?
Hi Maarten,
Try this CSS:
.inside-right-sidebar {
position: sticky;
top: 65px;
}
Feel free to adjust the value 65px to re-position the sticky sidebar.
Adding CSS: https://docs.generatepress.com/article/adding-css/
Hy Ying,
it works, great !!
Rolf
You are welcome :)
Thanks for sharing this. Is there a way to target only blog posts for the sticky sidebar? For example, when the sidebar moves on the Shop page, it can be kind of distracting especially if the page isn't very long. Thanks.
Hi Craig,
You can try modifying the CSS to something like:
.single-post .inside-right-sidebar {
position: sticky;
top: 65px;
}
.single-post targets posts.
Hope this helps! Kindly let us know how it goes. :)
Worked great. Thank you!
You’re welcome Craig! Glad to be of assistance! Feel free to reach out anytime you’ll need assistance with anything else. :)