[Resolved] Stick last widgets in right sidebar not working

Home Forums Support [Resolved] Stick last widgets in right sidebar not working

Home Forums Support Stick last widgets in right sidebar not working

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2342379
    Pintu

    Hi, I’ve added the following CSS to make the last widget sticky (AdSense Ad Code) in my sidebar

    @media(min-width: 769px) {
        .inside-right-sidebar {
            height: 100%;
        }
        .inside-right-sidebar .widget:last-child {
            position: -webkit-sticky;
            position: sticky;
            top: 60px;
        }
    }

    But it’s not working. Please help

    #2342383
    Fernando
    Customer Support

    Hi Pintu,

    Can you try #1 here?: https://docs.generatepress.com/article/debugging-tips/

    Something is adding an inline style height to your inside-right-sidebar which is not default and causing the code not to work.

    #2342386
    Pintu

    Found out the cause. I was using another Responsive ad unit above the sticky ad, just removed it, and it is now fine.

    #2342390
    Fernando
    Customer Support

    I see. Glad you found the issue.

    #2342391
    Pintu

    Hi, though the Ad is now sticky it is not center aligned.

    I’ve added the <div align="center"> and </div> but still it is not in center.

    #2342402
    Fernando
    Customer Support

    Try to add this CSS:

    .inside-right-sidebar .widget > div {
        display: flex;
        justify-content: center;
    }
    #2342407
    Pintu

    Yes, it worked!

    So, can I now remove <div> and </div> from the HTML?

    Thanks.

    #2342410
    Fernando
    Customer Support

    You can remove that, and change this:

    .inside-right-sidebar .widget:last-child {
            position: -webkit-sticky;
            position: sticky;
            top: 60px;
        }

    to this:

    .inside-right-sidebar .widget:last-child {
            position: -webkit-sticky;
            position: sticky;
            top: 60px;
    display: flex;
        justify-content: center;
        }

    and see if it works.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.