[Support request] Add a fixed button at the bottom of screen on mobile

Home Forums Support [Support request] Add a fixed button at the bottom of screen on mobile

Home Forums Support Add a fixed button at the bottom of screen on mobile

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2017225
    Ben

    Hi Guys,

    How would I add a sticky or fixed button on the bottom of the screen on mobile view?

    I’ve added an image of what I’m trying to achieve:

    Is this possible?

    Thanks

    #2017429
    David
    Staff
    Customer Support

    Hi there,

    Try this:

    1. Create a new Block Element:

    https://docs.generatepress.com/article/block-element-overview/

    2. Add a GB Container Block, with an Advanced > Additional CSS Class(es) of: hide-on-desktop hide-on-tablet sticky-mobile-footer

    3. Add your styles and button to the Container Block.

    4. Set the Block Element Hook to after_footer

    5. With the block published, then add this CSS to your site:

    .sticky-mobile-footer {
        position: -webkit-sticky;
        position: sticky;
        bottom: 0;
        z-index: 100000;
    }
    #2027157
    Ben

    Hi David,

    Thanks for this.

    Unfortunately, that hasn’t worked 🙁

    I’m not sure if I’ve done something wrong or not?

    Thanks

    #2027367
    David
    Staff
    Customer Support

    I can’t see the sticky-mobile-footer Element on that page?

    #2028056
    Ben

    This is how I’ve got it set up:

    I’ve got the CSS in place and it’s set to after-footer

    So what am I doing wrong?

    #2028174
    Ying
    Staff
    Customer Support

    Hi there,

    You have the hide-on-mobile class added to the container, I thought you want it to appear on mobile right?
    11.28.2021-12.25.10

    #2029009
    Ben

    OMG I’m so dumb!

    Thanks, it works now.

    Just a quick one though to tidy up.

    The bar is hiding under certain elements on the page (see image below):

    How do I bring it to the front?

    Thanks

    #2029031
    David
    Staff
    Customer Support

    I edited the CSS here:

    https://generatepress.com/forums/topic/add-a-fixed-button-at-the-bottom-of-screen-on-mobile/#post-2017429

    now has the z-index property which should keep it in front

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