Archived topic
Making a block element I've placed in the right sidebar sticky
3 replies · Started by Jon on June 20, 2021
Hi - I've built a custom block element that I am displaying in the right sidebar, underneath a widget, on one post only. All working great, but I want the block to be sticky and I can't seem to make that work.
I saw this post from Tom https://generatepress.com/forums/topic/sticky-sidebars/ so have been using that as a guide.
I've tried this CSS:
/* Sticky block in sidebars */
@media(min-width: 769px) {
.inside-right-sidebar .gb-inside-container {
position: -webkit-sticky;
position: sticky;
top: 60px;
}
}
And I've tried this CSS, where I'm targeting the specific block:
@media(min-width: 769px) {
.gb-container-4927c7ae {
position: -webkit-sticky;
position: sticky;
top: 60px;
}
}
Obviously, I'm doing something wrong.
Hi there,
try this CSS:
@media(min-width: 769px) {
.inside-right-sidebar {
height: 100%;
}
.make_sticky {
position: -webkit-sticky;
position: sticky;
top: 60px;
}
}
Awesome David, that works great. Thank you.
Maybe you guys should do a walk-thru of using blocks this way (I've watched Leo's other vids, but don't think this use case is covered) as a great way to create custom ads/banners that can be different per post (which traditionally people would have had to use a paid plugin for) and maybe there is a better way of doing it than the way I've approached it.
That way is probably the best way.
Yeah - interesting idea :)
Glad to be of help