Site logo

Archived topic

Add a fixed button at the bottom of screen on mobile

7 replies · Started by Ben on November 23, 2021

Viewing posts 1–8 of 8

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

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;
}

Hi David,

Thanks for this.

Unfortunately, that hasn't worked :(

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

Thanks

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

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?

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

This archived topic is closed to new replies.