Site logo

Archived topic

How to Hide Scroll to Top Mobile Position

8 replies · Started by Maarten on February 19, 2022

Viewing posts 1–9 of 9

Dear support,

I have a question about the option Scroll to Top.
I always find it very helpful that a user can scroll back to the top of the website but on mobile view I would like the position changed.

When it is now activated, it will not be next to the content on the right-side white-space on mobile, but it will cover the text.
Yes, I did make it very transparent but it still does not like nice.

I did try to move it more to the right of the content, but it is pretty hard, specially if you select a smaller mobile device on Chrome view/layout.

So, if this is not really possible, would it be possible to have the Scroll to Top appear when a user is at 90% down reading the content.

Have a look at the following website
//

Press CTRL + SHIFT + I and toggle mobile device view.

Scroll down the article and see the Scroll to Top appears at about 90% down the page from the right-side of the screen.
I do like that it flies-in from the right to the left.

If this is possible with GeneratePress that would be great.

Thanks!

Hi there,

This should help:
https://docs.generatepress.com/article/back-to-top-button/#moving-the-button

If you want to change the position specifically for mobile then wrap the code in @media (max-width: 768px) { } media query:
https://docs.generatepress.com/article/responsive-display/#responsive-breakpoints

If you want to hide it on mobile then this CSS should work:

@media (max-width: 768px) {
    .generate-back-to-top {
        display: none;
    }
}

Adding CSS: https://docs.generatepress.com/article/adding-css/

Let me know if this helps :)

Thank's a lot Leo!

I will try to create this.

If I understand it correctly I need to build the following:

Function: If I change this to only be active on mobile, ​I could ​make the scroll to top appear ​like 700px from the top, right?


);

}

CSS: I only need to have it show-up at the bottom right of the website on Mobile only.(In Footer section) But I have no idea how to CSS it for the function above.

@media (max-width: 768px) {
    .generate-back-to-top {

    }
}

Could you point me in the direction how to make this?

I do have a child theme with functions so yeah I wil place it in these files.

Function: If I change this to only be active on mobile, ​I could ​make the scroll to top appaer ​like 700px from the top, right?

This might be a little tricky to target mobile only but try this:

add_filter( 'generate_back_to_top_start_scroll', 'tu_back_to_top_start_scroll' );
function tu_back_to_top_start_scroll() {
    if ( wp_is_mobile() ) {
        return 300; // 300px from the top
    }
}

As for the position, take a look at the definition here:
https://www.w3schools.com/cssref/pr_pos_bottom.asp
https://www.w3schools.com/cssref/pr_pos_left.asp

Leo, I just realized I made the thing I like more complex than needed.
Of course it should be styled for Desktop the same as Mobile. (Also better for Google)

Because than it just appears on Desktop at the same place as Mobile.

If then I only need the above function, it will be perfect.

Thanks a lot!

I put the following in my child theme:

if ('1' ) {
}

I am sorry but I do not understand what to do, the links you gave me are for me to complex.

I would really like the Scroll to top button just only appear at the end of the footer so that it will not cover the written text.

If it is not possible maybe there is a scroll to top plugin that is easier for me to implement?

Thanks for your support.

I would really like the Scroll to top button just only appear at the end of the footer so that it will not cover the written text.

I'm not sure if that's possible unfortunately - the filter we use only allows us to set a static height in px and the length of every page is different.

I'm not sure if there is a back to top plugin that will offer this option either.

Thanks for your reply Leo.

Yeah, I just need to make a button in the footer that will go back to top using #top, but it will not scroll.

I am not really worry that this is not possible, there is so much possible using GP that I understand we cannot have everything we want of course.

Yeah, every length of page is different. It would be nice to have it appear like the URL in my opening post at the bottom above every footer that is visible on a page, maybe a option for the next version. (This will prevent it floating above written text)

Thanks for your support, for now I just leave it disabled everywhere.

No problem :)

This archived topic is closed to new replies.